View Single Post
Old 04-25-2012, 05:29 AM   PM User | #1
loopsnhoops
New Coder

 
Join Date: Aug 2011
Posts: 24
Thanks: 6
Thanked 0 Times in 0 Posts
loopsnhoops is an unknown quantity at this point
Unhappy PHP MYSQL SELECT Handling problems

Hi,

I have been trying to display my data from two columns onto a table in html. I am using myhosting.com and I am new to their system. I had just started thinking I had gotten a grasp on how to use their PHPMyAdmin and MYSQL system but then I got an odd error. Can you please tell me if this is their system's fault or the result of my bad coding?

Thanks and offered solutions will result in many thanks!

Here is the code:

PHP Code:
<?php
            
        $Server
="xxxx";
        
$User="xxxx";
        
$Password="xxxx";
        
$Database="xxxx";

$connection mysql_connect($Server$User$Password);
if(!
$connection){
    die(
"Couldn't Connect" mysql_error());
}
echo 
"Connection Working";

mysql_select_db($Database$connection);

$query "SELECT * FROM Test";

$table mysql_query($query,$connection);

echo 
"<table border='1'>";
echo 
"<tr> <th>id</th> <th>name</th> </tr>";
// keeps getting the next row until there are no more to get
while($row mysql_fetch_array$query )) {
    
// Print out the contents of each row into a table
    
echo "<tr><td>"
    echo 
$row['id'];
    echo 
"</td><td>"
    echo 
$row['name'];
    echo 
"</td></tr>"
}  

echo 
"</table>";
            
?>
and here is the error:

Connection Working Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /usr/local/pem/vhosts/113282/webspace/httpdocs/show.php on line 23
id name
Resource id #3
loopsnhoops is offline   Reply With Quote