Results 1 to 4 of 4

Thread: php error

  1. #1
    Join Date
    Jan 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default php error

    Am having an error on line 63 when a run this php code..
    config.php

    Code:
    <?php
    $mysql_hostname = "localhost";
    $mysql_user = "root";
    $mysql_password = "";
    $mysql_database = "bankdb";
    $bd = mysql_connect($mysql_hostname, $mysql_user, $mysql_password) 
    or die("Opps some thing went wrong");
    mysql_select_db($mysql_database, $bd) or die("Opps some thing went wrong");
    ?>
    
    
    the error was found on this code
    
    <?php require_once('config.php');?>
    <?php
    //initialize the session
    if (!isset($_SESSION)) {
      session_start();
    }
    
    // ** Logout the current user. **
    $logoutAction = $_SERVER['PHP_SELF']."?doLogout=true";
    if ((isset($_SERVER['QUERY_STRING'])) && ($_SERVER['QUERY_STRING'] != "")){
      $logoutAction .="&". htmlentities($_SERVER['QUERY_STRING']);
    }
    
    if ((isset($_GET['doLogout'])) &&($_GET['doLogout']=="true")){
      //to fully log out a visitor we need to clear the session varialbles
      $_SESSION['MM_Username'] = NULL;
      $_SESSION['MM_UserGroup'] = NULL;
      $_SESSION['PrevUrl'] = NULL;
      unset($_SESSION['MM_Username']);
      unset($_SESSION['MM_UserGroup']);
      unset($_SESSION['PrevUrl']);
    	
      $logoutGoTo = "mainpage.php";
      if ($logoutGoTo) {
        header("Location: $logoutGoTo");
        exit;
      }
    }
    ?>
    <?php
    if (!function_exists("GetSQLValueString")) {
    function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
    {
      if (PHP_VERSION < 6) {
        $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
      }
    
      $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
    
      switch ($theType) {
        case "text":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
          break;    
        case "long":
        case "int":
          $theValue = ($theValue != "") ? intval($theValue) : "NULL";
          break;
        case "double":
          $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
          break;
        case "date":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
          break;
        case "defined":
          $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
          break;
      }
      return $theValue;
    }
    }
    mysql_select_db($mysql_database, $bd);
    $query_Recordset1 = "SELECT * FROM users";
    $Recordset1 = mysql_query($query_Recordset1, $db) or die(mysql_error());
    $row_Recordset1 = mysql_fetch_assoc($Recordset1);
    $totalRows_Recordset1 = mysql_num_rows($Recordset1); 
    ?> 
    
    from here down
    mysql_select_db($mysql_database, $bd);
    $query_Recordset1 = "SELECT * FROM users";
    $Recordset1 = mysql_query($query_Recordset1, $db) or die(mysql_error());
    $row_Recordset1 = mysql_fetch_assoc($Recordset1);
    $totalRows_Recordset1 = mysql_num_rows($Recordset1); 
    ?>
    Last edited by djr33; 01-26-2010 at 05:57 AM.

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    1. What is the error (and can you point out the line, rather than just pasting the whole code)?
    2. Post new questions in new threads.
    3. Use [black] tags around code so it is easily readable.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  3. #3
    Join Date
    Jan 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    when a run with my browser i get this error
    Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in C:\xampp\htdocs\alex\html\accountpage.php on line 63
    i guess is from this part of the code

    mysql_select_db($mysql_database, $bd);
    $query_Recordset1 = "SELECT * FROM users";
    $Recordset1 = mysql_query($query_Recordset1, $db) or die(mysql_error());.......................line 64
    $row_Recordset1 = mysql_fetch_assoc($Recordset1);
    $totalRows_Recordset1 = mysql_num_rows($Recordset1);

  4. #4
    Join Date
    Sep 2008
    Location
    Bristol - UK
    Posts
    842
    Thanks
    32
    Thanked 132 Times in 131 Posts

    Default

    The problem is that you've declared your database as $bd, not $db.

    Change the mysql_query line to:

    PHP Code:
    $Recordset1 mysql_query($query_Recordset1$bd) or die(mysql_error()); 
    See if that fixes it

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •