Jump to content

Another Error!


Mod-Jay

Recommended Posts

Error:

 

Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\Users\cory\Desktop\xampp\htdocs\Starter Kit(2)\admincp\pages\news.php on line 40

 

Code:

 

	                <?php		$result = mysql_query("SELECT * FROM blog ORDER BY desc");		//the while loop		while($r=mysql_fetch_array($result))		{$id=$r["ID"];$name=$r["name"];$desc=$r["descr"];$date=$r["date"];echo "<tr><td>News Name: $name</td><td>News Desc: $desc</td><td>Date Posted: $date</td><td><a href='edit.php'>Edit</a></td><td><a href='news.php?action=delete&id=$id'>Delete $name</a></td></tr>";}?>

 

Line 40:

 

while($r=mysql_fetch_array($result))

 

Link to comment
Share on other sites

This usually means there was a problem with your query. Change

 

$result = mysql_query("SELECT * FROM blog ORDER BY desc");

 

to

 

$result = mysql_query("SELECT * FROM blog ORDER BY desc") or trigger_error('Query Error: ' . mysql_error(), E_USER_ERROR);

 

What error is shown now?

Link to comment
Share on other sites

Thats it :P

 

Fatal error: Query Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'desc' at line 1 in C:\Users\cory\Desktop\xampp\htdocs\Starter Kit(2)\admincp\pages\news.php on line 38

 

 

Line 38 Is the Query. Wild Gave me

Link to comment
Share on other sites

Then you need to specify the field to order the results by. If its the id field then your query should be

SELECT * FROM blog ORDER BY id DESC

That will order the results by the id field in descending order (eg 5, 4, 3, 2, 1). To order in ascending order (eg 1, 2, 3, 4, 5 etc) you'd change DESC to ASC

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.