Strange Guestbook Problem

software development

#1

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


#2

NEVERMIND-

Figured it out :slight_smile:


#3

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.


[color=#6600CC]Norm[/color]

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.


#4

Norm,
I love your disclaimer.lol.
Silk


#5

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’)


[color=#6600CC]Norm[/color]

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.