-6

Possible Duplicate:
mysql_fetch_array() expects parameter 1 to be resource, boolean given in select

EDITED! Okay, I have like 3 Errors on my website. These are the errors that pop up. Connection Info:

$dbhost     = '127.0.0.1';
$dbdatabase = 'bans';
$dbuser     = 'dsfhalsfdh';
$dbpassword = 'lfhdjklfdf';
$webname    = 'InsanityRP.Com'

This are the errors:

Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in /home/klayplex/public_html/insanityrp.com/bans/index.php on line 41

Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in /home/klayplex/public_html/insanityrp.com/bans/index.php on line 68

My Code Goes In Order:

                        $result = mysql_fetch_array(mysql_query($query));

Then

                        while($row=mysql_fetch_assoc($result)){     

Anything look weird? I don`t know PHP at all, so if you can, please tell me what to edit or just give me the code to copy and paste.

Community
  • 1
  • 1

5 Answers5

1
  1. First one you've got $resul1 instead of $result
  2. second error is because you're expecting results, but mysql_query() returns a boolean on error, so you've probably got an issue with your query
  3. Finally your last query has the same typo as the first with $resul1 instead of $result.
ernie
  • 6,257
  • 22
  • 27
1

That's funny one.
You have an extra call to mysql_fetch_array, which returns an array, not a resource.

Also, go not try stuff as many operators as you can in one line like this

$result = mysql_fetch_array(mysql_query($query));

write them separately, along with some error checking

$query = "SELECT ...";
$result = mysql_query($query) or trigger_error(mysql_error()."[$query]");
while($row=mysql_fetch_assoc($result)){
Your Common Sense
  • 154,967
  • 38
  • 205
  • 325
0

Your $result is misspelled as $resul1. It's a typo.

EDIT: mysql_query() returns false (which is a boolean) when it fails. Use mysql_error() to find out what the error was. I suggest you to rewrite

$result = mysql_fetch_array(mysql_query($query));

into

$resultSet = mysql_query($query);
print mysql_error();    // Print the error message.
$result = mysql_fetch_array($resultSet);
Pang
  • 9,073
  • 146
  • 84
  • 117
0

while($row=mysql_fetch_assoc($resul1)){

to

while($row=mysql_fetch_assoc($result))

Mudassir Hasan
  • 26,910
  • 19
  • 95
  • 126
0

Change $resul1 to $result and dont ask again like this questions.It will be difficult for catching problem with only that error.Consider using mysql_error() this can help finding the right problem.

harikrishnan.n0077
  • 1,757
  • 4
  • 19
  • 27