By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,943 Members | 1,875 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,943 IT Pros & Developers. It's quick & easy.

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

P: 2
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:
Expand|Select|Wrap|Line Numbers
  1. <?php 
  2. /*program
  3.  * 
  4.  */
  5.  echo "<html><head><title>Test Mysql</title></head>
  6.  <body>";
  7.  $host="localhost";
  8.  $user="freddwit_peter";
  9.  $password="thinkbig1102";
  10.  
  11.  $cxn=mysql_connect($host, $user, $password);
  12.  $sql="SHOW STATUS";
  13.  $result=mysql_query($cxn, $sql);
  14.  if ($result == FALSE) {
  15.  echo "<h4>Error: ".mysqli_error($cxn)."</h4>"    ;
  16.  } 
  17.  else 
  18.  {
  19.      /*table that displays results*/
  20.      echo "<table border='1'>
  21.            <tr><th>Variable name</th>
  22.                <th>Value</th></tr>";
  23.      echo "<tr>";
  24.  $row_array= mysql_fetch_row($result);
  25.    for ($j = 0;j <mysqli_num_fields($result); $j++)
  26.    {
  27.     echo "<td>".$row_array[$j]."</td>\n";
  28.     }
  29.      echo "</table>";
  30.  }
  31.  ?>
  32.  </body></html>
  33.  
Oct 14 '11 #1

✓ answered by johny10151981

read manual.
Expand|Select|Wrap|Line Numbers
  1. //your code is like this
  2. mysql_query($cxn, $sql);
  3. //but it should be
  4. mysql_query($sql,$cxn);
  5.  
You must have to read php manual to implement php function

Share this Question
Share on Google+
2 Replies


100+
P: 1,059
read manual.
Expand|Select|Wrap|Line Numbers
  1. //your code is like this
  2. mysql_query($cxn, $sql);
  3. //but it should be
  4. mysql_query($sql,$cxn);
  5.  
You must have to read php manual to implement php function
Oct 14 '11 #2

Dormilich
Expert Mod 5K+
P: 8,639
you can also not mix mysql with mysqli.
Oct 14 '11 #3

Post your reply

Sign in to post your reply or Sign up for a free account.