Jump to content

[SOLVED] Invalid array ?


ambo

Recommended Posts

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/content/d/e/c/decuralogin/html/profile.php on line 126

      <?
include("Process/dbconnect.php");
$sql="SELECT * FROM userinfo ORDER BY id DESC LIMIT 1";
// OREDER BY id DESC is order result by descending 
$result=mysql_query($sql);
while($rows=mysql_fetch_array($result)){
?>
<table width="269" cellspacing="0" cellpadding="0">
  <tr>
    <td width="76"><div align="right">First Name:</div></td>
    <td width="191"><?php echo $rows['fname']; ?> </td>
  </tr>
  <tr>
    <td><div align="right">Last Name:</div></td>
    <td><?php echo $rows['lname']; ?> </td>
  </tr>
  <tr>
    <td><div align="right">State:</div></td>
    <td><?php echo $rows['state']; ?> </td>
  </tr>
  <tr>
    <td><div align="right">Steamid:</div></td>
    <td><?php echo $rows['steamid']; ?> </td>
  </tr>
</table>


<?
}
mysql_close();
?>

Link to comment
https://forums.phpfreaks.com/topic/147503-solved-invalid-array/
Share on other sites

in that query you are only asking for the last id result by setting LIMIT 1, try removing this limit

 

the only other thing from that I can see would be to check the table name is called userinfo and there is a column called id, these are usually also case sensitive. I am also assuming that the code there is also from around line 126

Link to comment
https://forums.phpfreaks.com/topic/147503-solved-invalid-array/#findComment-774359
Share on other sites

It seems like you have a mysql query error. Try this

 

Find:

$result=mysql_query($sql);

Replace with:

$result=mysql_query($sql) or die(mysql_error());

 

and see if any errors show up...

 

also your second mistake is mysql_fetch_array keys are put in numbers so it would really be $rows[0]; but there is a way to fix that

 

from changing

while($rows=mysql_fetch_array($result)){

to

while($rows=mysql_fetch_array($result, MYSQL_ASSOC)){

 

or

 

changing fetch_array to fetch_assoc =)

Link to comment
https://forums.phpfreaks.com/topic/147503-solved-invalid-array/#findComment-774361
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.