Jump to content

Mysql_fetch_array Issue


Neosocrates

Recommended Posts

Hey,

 

I have been having a problem with this code for a while now where I connect to the MySQL database to retrieve the desired information, but always get an error message. I have tried to correct it myself by changing bits of the code and searched the internet, but still have no idea how to fix it. Any help would be appreciated.

 

The error is as follows:

 

Notice: An error occured1: in <filelocation> on line 18

 

Warning: mysql_fetch_array() expects parameter 1 to be resource, null given in <filelocation> on line 21

 

Notice: An error occured2: in <filelocation> on line 15

 

My code as is follows:

 

require_once('../mysqli_connect.php') ; 

$query = "SELECT * FROM database WHERE mem_id='".($_GET['id'])."'";
$result = @mysql_query($dbc, $query) OR trigger_error("An error occured1: " . mysql_error());
$row = mysql_fetch_array($result) OR trigger_error("An error occured2: " . mysql_error());

echo "<b>Date: </b> ".$row['date'];
echo "<br><b>ID: </b> ".$row['mem_id'];

 

Thanks.  :)

Link to comment
Share on other sites

I removed that previously, and did so again, but still have exactly the same problem.

 

If I establish a connection with the database using

mysql_connect("localhost", "root", "password") or trigger_error("MySQL Connection Failed: " . mysql_error());
mysql_select_db("dbname") or trigger_error("MySQL Select DB Failed: " . mysql_error());

 

Then I have no problem retrieving the data. It is when I access the file through the require_once function that the problem occurs.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.