0

Dear Sir,

I have following codes

<?php
mysql_connect("localhost", "root", "") or die("Connection failed! " . mysql_error());
mysql_select_db("asia");
echo "Connection successful!";
$find_query = "select *FROM  ghee where sno=3";
$strSQL = mysql_query($find_query);
// Execute the query (the recordset $rs contains the result)
    $rs = mysql_query($strSQL); 
    // Loop the recordset $rs
    // Each row will be made into an array ($row) using mysql_fetch_array
    while($row = mysql_fetch_array($rs)) {
       // Write the value of the column FirstName (which is now in the array $row)
      echo $row['pack'] . "<br />";
      }
mysql_close();
?>

It shows error message show in attachment

( ! ) Warning: mysql_query() expects parameter 1 to be string, resource given in C:\wamp\www\find.php on line 8
Call Stack
#   Time    Memory  Function    Location
1   0.0780  141360  {main}( )   ..\find.php:0
2   0.4836  149584  mysql_query ( )
..\find.php:8

( ! ) Warning: mysql_fetch_array() expects parameter 1 to be resource, null given in C:\wamp\www\find.php on line 11
Call Stack
#   Time    Memory  Function    Location

My table structure can be seen in this link
http://www.phphelp.com/forum/code-snippets/parameter-problem/?action=dlattach;attach=171

Please help me to get rid of both error messages

3
Contributors
2
Replies
14
Views
3 Years
Discussion Span
Last Post by Bachu
0

Please help me to get rid of both error messages

@tqmd1

Your php mysql functions are out of dated, update it you mysqli or pdo function.

The reason is that if you used the same code and update the function, it would work.

0

You did double exicution of query.. I have done the changes and it works for me.

Please check ...

<?php
mysql_connect("localhost", "root", "") or die("Connection failed! " . mysql_error());
mysql_select_db("asia") or  die("Error in database selection" . mysql_error());
echo "Connection successful!";
$find_query = "select *FROM ghee where sno=3";
$strSQL = mysql_query($find_query);
// Execute the query (the recordset $rs contains the result)
//$rs = mysql_query($strSQL);
// Loop the recordset $rs
// Each row will be made into an array ($row) using mysql_fetch_array
while($row = mysql_fetch_array($strSQL)) {
// Write the value of the column FirstName (which is now in the array $row)
echo $row['pack'] . "<br />";
}
mysql_close();
?>

Edited by Bachu: correction

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.