PDA

View Full Version : Not working T_String Error?


Labbat
02-02-2004, 06:04 PM
Hey guys, for some reason, I can't get this to work, basically its just a table that gets data-from a database, and displays it in the table, now the error I get is:
Parse error: parse error, unexpected T_STRING in c:\program
files\apache group\apache\htdocs\displaydb.php on line 17

So naturally I check line 17, I can't see anything wrong with it, do you?

Now, the file is DisplayDB.php, and the code for it is below

<HTML>
<HEAD>
<Title>Retrieving Data From a Database</title>
<BODY>
<?php
//Set the variables for the database access:
$Host = "localhost";
$DBName = "New";
$TableName = "Feedback";

$Link = mysql_connect($Host);

$Query = "SELECT * from $TableName;
$Result = mysql_db_query($DBName, $Query, $Link);

//Create a table.
print("<TABLE BORDER=1 WIDTH=\"75%\"
CELLSPACING=2 CELLPADDING=2
ALIGN=CENTER>\n");
print("<TR ALIGN=CENTER
VALIGN=TOP>\n");
print ("<TD ALIGN=CENTER
VALIGN=TOP>Name</TD>\n");
print ("<TD ALIGN=CENTER
VALIGN=TOP>Email Address</td>\n");
print ("<TD ALIGN=CENTER
VALIGN=TOP>Comments</td>\n");
print ("</TR>\n");

// Fetch the results from the database.
while ($Row = mysql_fetch_array
($Result)) {
print ("<TR ALIGN=CENTER
VALIGN=TOP\n");
print ("<TD ALIGN=CENTER
VALIGN=TOP>$Row[FirstName]
$Row[LastName]</TD>\n");
print ("TD ALIGN=CENTER VALIGN=TOP
$Row[EmailAddress]</TD>\n");
print ("<TD ALIGN=CENTER
VALIGN=TOP>$Row[Comments]</TD>\n");
print ("<TR>\n");
}
mysql_close($Link);
print ("<TABLE>\n");
?>
</BODY>
</HTML>

mordred
02-02-2004, 06:40 PM
You lost one double quote at the end of your query variable:


$Query = "SELECT * from $TableName;


should be


$Query = "SELECT * from $TableName";

Spookster
02-02-2004, 06:46 PM
You forgot to terminate a sting here:

$Query = "SELECT * from $TableName;

Beat me to it. Wow how did I not see your post mordred? :)

Labbat
02-02-2004, 07:06 PM
lol! I didn't even notice that, and I looked at that line for like 10 minutes... hahaha..
Im a ******* lol... Alright guys thanks allot for the help

Spookster
02-02-2004, 08:07 PM
Originally posted by Labbat
lol! I didn't even notice that, and I looked at that line for like 10 minutes... hahaha..
Im a ******* lol... Alright guys thanks allot for the help

Watch your language in our forums!