Strange Guestbook Problem

Strange Guestbook Problem

Posted by: superpwnage
Posted on: 2006-05-21 10:45:00

I am trying to extract the posts out of a database using this code-

$sql="SELECT * FROM guestbook ORDER BY id desc;";
$result=mysql_query($sql,$conn) or die(mysql_error());
while ($gbarray = mysql_fetch_array($result,$conn)){
$name=$gbarray['name'];
$email=$gbarray['email'];
$message=$gbarray['message'];
textbox("$name - $email","$message");
}

Yet, it is not working. I am not getting any "official" errors, however the variables are returning as blank. I did run some tests-

- I echo'd the number of rows being returned which came out as 2, which is correct.

- I also echo'd the variables, $name, $email, and $message, yet nothing was returned.

- Then I set up the code on a different page, seperate from anything else and the variables still returned blank, which shows that the problem lies in the bit of code I posted

The textbox() function is just setting up the tables with a header (the first argument) and the content (the second argument). This part is working as the textboxes are showing up, along with the " - " in the header.

What remains unkown is why the variables are coming up as blank.

Any help is appreciated,

Ben

Re: Strange Guestbook Problem

Posted by: superpwnage
Posted on: 2006-05-21 11:14:00

NEVERMIND-

Figured it out :)

Re: Strange Guestbook Problem

Posted by: norm1037
Posted on: 2006-05-21 11:14:00

Is that ; after desc a typo?
Should it be:-

$sql="SELECT * FROM guestbook ORDER BY id DESC";
instead of
$sql="SELECT * FROM guestbook ORDER BY id desc;";

to sort descending.


--
Norm

Opinions are my own views and are not the views of DreamHost.
Any advice offered by me should be acted upon only at your own risk.

Re: Strange Guestbook Problem

Posted by: silkrooster
Posted on: 2006-05-21 14:54:00

Norm,
I love your disclaimer.lol.
Silk

Re: Strange Guestbook Problem

Posted by: norm1037
Posted on: 2006-05-22 03:04:00

I could not fit in the 18 pages of conditions so I had to compromise. Trouble is that by the time my legal team have scrutinised my replies three weeks have gone by!

I stayed up all night wondering about what the fix was for his guestbook. I may never sleep again!

(Time and date disclaimer: Please replace 'three weeks' with 'a period between zero and infinity')





--
Norm

Opinions are my own views and are not the views of DreamHost.
Any advice offered by me should be acted upon only at your own risk.

Tags: email messagemysql errormysql querysql selectconnechoseperatefetch