Jump to content

What's wrong?...again.


dudejma

Recommended Posts

Thanks for all your help! I really appreciate it. I'm trying to show data from a table and this is the error I get:

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/virtu857/public_html/aandwtechsupport.co.cc/newusers.php on line 26

 

Here is newusers.php:

<?php
$con = mysql_connect("localhost","virtu857_newuser","mypassword");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("virtu857_newusers", $con);

$result = mysql_query("SELECT * FROM Persons");

echo "<table border='1'>
<tr>
<th>First Name</th>
<th>Last Name</th>
<th>Address</th>
<th>City</th>
<th>State</th>
<th>Zip</th>
<th>Phone</th>
<th>Email</th>
<th>Username</th>
<th>Password</th>
</tr>";

while($row = mysql_fetch_array($result))
  {
  echo "<tr>";
  echo "<td>" . $row['firstname'] . "</td>";
  echo "<td>" . $row['lastname'] . "</td>";
  echo "<td>" . $row['address'] . "</td>";
  echo "<td>" . $row['city'] . "</td>";
  echo "<td>" . $row['state'] . "</td>";
  echo "<td>" . $row['zip'] . "</td>";
  echo "<td>" . $row['phone'] . "</td>";
  echo "<td>" . $row['email'] . "</td>";
  echo "<td>" . $row['username'] . "</td>";
  echo "<td>" . $row['password'] . "</td>";
  echo "</tr>";
  }
echo "</table>";

mysql_close($con);
?> 

Link to comment
https://forums.phpfreaks.com/topic/207315-whats-wrongagain/
Share on other sites

The error indicates that the mysql_query has failed, meaning it didn't return a valid MySQL resource.

 

$result = mysql_query("SELECT * FROM Persons") or die("Error: " . mysql_error());

 

There should be a heap of related topics to this kind of problem, even Googling will return thousands of hits. Try searching for something this common next time.

Link to comment
https://forums.phpfreaks.com/topic/207315-whats-wrongagain/#findComment-1083909
Share on other sites

Oh. I'm sorry.  :(  I have no knowledge of PHP.  :shrug:

 

Having knowledge of PHP isn't the problem. I merely suggested when you encounter problems, you look into why you encountered that problem. Follow a simple rule, attempt to solve the problem yourself. If you have no luck their, then turn to the almighty Google. Try searching for a few different things about your problem. Also search on Stack Overflow or even this forum for answers. Ask a friend who also codes. Finally, if after all that you're still stumped then ask on a forum.

 

In regards to your problem, I've noticed you're using a capital letter in your table name. I've never used capitals in a table name, nor have I seen others use it. Not sure if it could have anything to do with your problem though.

Link to comment
https://forums.phpfreaks.com/topic/207315-whats-wrongagain/#findComment-1083911
Share on other sites

Archived

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

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.