Error: supplied argument is not a valid MySQL-Link resource

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • peterbwoj
    New Member
    • Oct 2011
    • 2

    Error: supplied argument is not a valid MySQL-Link resource

    Why am I getting this error

    Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /home/freddwit/public_html/test.php on line 13

    Warning: mysqli_error() expects parameter 1 to be mysqli, resource given in /home/freddwit/public_html/test.php on line 15
    Error:

    Here is my code:
    Code:
    <?php 
    /*program
     * 
     */
     echo "<html><head><title>Test Mysql</title></head>
     <body>";
     $host="localhost";
     $user="freddwit_peter";
     $password="thinkbig1102";
     
     $cxn=mysql_connect($host, $user, $password);
     $sql="SHOW STATUS";
     $result=mysql_query($cxn, $sql);
     if ($result == FALSE) {
     echo "<h4>Error: ".mysqli_error($cxn)."</h4>"	;
     } 
     else 
     {
     	/*table that displays results*/
     	echo "<table border='1'>
     	      <tr><th>Variable name</th>
     	          <th>Value</th></tr>";
     	echo "<tr>";
     $row_array= mysql_fetch_row($result);
       for ($j = 0;j <mysqli_num_fields($result); $j++)
       {
    	echo "<td>".$row_array[$j]."</td>\n";
    	}
     	echo "</table>";
     }
     ?>
     </body></html>
  • johny10151981
    Top Contributor
    • Jan 2010
    • 1059

    #2
    read manual.
    Code:
    //your code is like this
    mysql_query($cxn, $sql);
    //but it should be
    mysql_query($sql,$cxn);
    You must have to read php manual to implement php function

    Comment

    • Dormilich
      Recognized Expert Expert
      • Aug 2008
      • 8694

      #3
      you can also not mix mysql with mysqli.

      Comment

      Working...