Jump to content

Viewing Database Table Content.


nielcleo

Recommended Posts

Hi, Anyone here please help me viewing the database table content.. i have only the infodatabase name, table name, user and password of the database.. i tried to use this

<?php$con = mysql_connect("localhost,"user","password");if (!$con)  {  die('Could not connect: ' . mysql_error());  }mysql_select_db("mydb", $con);$result = mysql_query("SELECT * FROM char ORDER BY DESC");while($row = mysql_fetch_array($result)){echo "<table border='1' width='100%'><tr>";echo  "<td>" .$row['char_id']. "</td>";echo  "<td>" .$row['name']. "</td>";echo  "<td>" .$row['str']. "</td>";echo  "<td>" .$row['agi']. "</td>";echo  "<td>" .$row['max_hp']. "</td>";echo  "<td>" .$row['hp']. "</td>";echo "</tr></table>";}?>

but it has an error Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/nielcle1/public_html/haha.php on line 12 here the code in line 12while($row = mysql_fetch_array($result)) please anyone help me

Link to comment
Share on other sites

The query is wrong. The mistake is actually on this line:

$result = mysql_query("SELECT * FROM char ORDER BY DESC");

Most likely, the table "char" doesn't exist, or you haven't selected a database.To test for errors, check that $result isn't false. If it is, then check mysql_error().

if(!$result) {  echo mysql_error();  exit;}

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...