Warning: mysql_fetch_row () expects parameter 1 to be a resource

Possible duplicate:
mysql_fetch_array () expects parameter 1 to be a resource, boolean is set to select

I get the message below when I run this script:

Warning: mysql_fetch_row () expects parameter 1 to be a resource, the line is specified in /var/www/html/toolkit/routing.php on line 12

I ran the query in mysql console and it will print the correct line. Not sure why I can't display it in php?

routing.php page:

<?php error_reporting(E_ALL); ////error_reporting(0); ini_set('display_errors', 'On'); include("db/sbc_config.php"); include("db/mysql.class.php"); $db = new MySQL(true, DB_DATABASE_ROUTING, DB_SERVER, DB_USER , DB_PASS); if ($db->Error()) $db->Kill(); $searchroute = "SELECT * FROM destination_route as d WHERE d.destPrefix='2146811'"; $result = mysql_fetch_row($searchroute); echo $result; ?> 

sbc_config.php:

 <?php //database server define('DB_SERVER', "10.10.1.146"); //database login name" define('DB_USER', "user"); //database login password define('DB_PASS', "pasword"); //database names define('DB_DATABASE_ROUTING', "routing"); //smart to define your table names also define('TABLE_DESTINATION_ROUTE', "destination_route"); ?> 
+4
source share
4 answers

mysql_fetch_row takes the cursor and returns the next row in this cursor. You are trying to give it a string. You are missing a step.

First you need to execute this query:

 $cursor = mysql_query($searchroute); // for example $result = mysql_fetch_row($cursor); 
+7
source

You must complete the query before you can get the results:

 $searchroute = "SELECT * ..."; $results = mysql_query($searchroute); $row = mysql_fetch_row($results); 
+2
source

mysql_fetch_row should be called after mysql_query, you cannot pass the query to the fetch string - see the PHP manual

0
source
 $db = new MySQL(true, DB_DATABASE_ROUTING, DB_SERVER, DB_USER , DB_PASS); 

Is this what MySQLi should be? Mysql _ * () functions do not have an OOP interface. You will put up with mysqli and mysql calls that are not supported. They are completely independent of each other inside, and the db descriptor or the result from one cannot be used in the other.

0
source

All Articles