Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Oct 2011
    Posts
    116
    Thanks
    19
    Thanked 1 Time in 1 Post

    Parameter Problem

    Dear Sir,

    I have following codes

    Code:
    <?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 show 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-sn...ach;attach=171

    Please help me to get rid of both error messages

  • #2
    New Coder
    Join Date
    Nov 2013
    Posts
    20
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Working code

    Code:
    <?php
        mysql_connect("localhost", "root", "") or die("Connection failed! " . mysql_error());
    
        mysql_select_db("asia");
    
    echo "Connection successful! <br />";
    $find_query = mysql_query("SELECT *FROM ghee WHERE sno='3'");
    
    	while($row = mysql_fetch_array($find_query)) {
    	   // Write the value of the column FirstName (which is now in the array $row)
    	  echo $row['pack']  . "<br />";
    	  }
    mysql_close();
    ?>
    
    Gojavo.com
    If this works tell me, if it works be sure to visit my search engine I created using only notepad at gojavo[dot]com click on an ad too, and tell folks about it

  • #3
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,854
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    $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);
    The highlighted line is useless. You have already executed the query in the above statement.

    Change your code to
    Code:
    $find_query = "select *FROM  ghee where sno=3";
    $rs = mysql_query($find_query);
    // Execute the query (the recordset $rs contains the result)
    	
    	// Loop the recordset $rs
    	// Each row will be made into an array ($row) using mysql_fetch_array
    	while($row = mysql_fetch_array($rs)) {
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)


  •  

    Posting Permissions

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