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
https://forums.phpfreaks.com/topic/218626-mysql_fetch_array-issue/
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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.