Forum Moderators: coopster

Message Too Old, No Replies

parse error

         

chhayrithy

10:56 pm on Dec 11, 2005 (gmt 0)

10+ Year Member



i'm getting the following error:

Parse error: parse error, unexpected T_STRING in /www/g/gwecaasu2006/htdocs/getRegistration.php on line 24

in the following code:

echo "<table>\n";
while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
echo "\t<tr>\n";
foreach ($line as $col_value) {
echo "\t\t<td>$col_value</td>\n";
}
echo "\t</tr>\n";
}
echo "</table>\n";

can anybody let me know what i'm doing wrong?

thanks!

dreamcatcher

3:08 am on Dec 12, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi chhayrithy, welcome to Webmaster World. :)

Can`t see any problems in the code you posted. Sometimes when an error points to a specific line, the error is on the line before. Check line 23.

dc

maxi million

11:15 am on Dec 12, 2005 (gmt 0)

10+ Year Member



agree with dreamcatcher

can't see any error here, in the piece of code you have posted

but you might want to do this:


echo "<table>\n";
while ($line = mysql_fetch_array($result, MYSQL_ASSOC))
{
echo "\t<tr>\n";
foreach ($line as $col_value)
{
echo "\t\t<td>".$col_value."</td>\n";
}
echo "\t</tr>\n";
}
echo "</table>\n";

hope it helps

chhayrithy

1:41 pm on Dec 12, 2005 (gmt 0)

10+ Year Member



Thank you both for your replies. Here is the entire PHP code:

<?
/* declare some relevant variables */
$DBhost = "mysql16.powweb.com";
$DBuser = "****";
$DBpass = "****";
$DBName = "gwregistration";
$table = "registration";

mysql_connect($DBhost,$DBuser,$DBpass) or die("Unable to connect to database");
@mysql_select_db("$DBName") or die("Unable to select database $DBName");
$sqlquery = "SELECT * FROM $table;
$result = mysql_query($sqlquery);

echo "<table>\n";
while ($line = mysql_fetch_array($result, MYSQL_ASSOC))
{
echo "\t<tr>\n";
foreach ($line as $col_value)
{
echo "\t\t<td>".$col_value."</td>\n";
}
echo "\t</tr>\n";
}
echo "</table>\n";

if(mysql_num_rows($result)<1){
echo "<font face=Arial size=+0><b>No
Results!</b></font><br>";
}

mysql_free_result($result);
?>

</body></html>

i've been looking it over and over and can't find anything. i'm fairly new to php, but this was basically copied over from a tutorial and i can't seem to see where the error is. the current error i'm getting now is:

Parse error: parse error, unexpected '>' in /www/g/gwecaasu2006/htdocs/getRegistration.php on line 23

thanks again!

dreamcatcher

2:13 pm on Dec 12, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This line:

$sqlquery = "SELECT * FROM $table;

Is it missing a "?

Should it be:

$sqlquery = "SELECT * FROM $table";

dc

chhayrithy

2:40 pm on Dec 12, 2005 (gmt 0)

10+ Year Member



thanks again dreamcatcher

i found the error. i was missing a line:

$number = mysql_numrows($result);

thanks again for all your help!

dreamcatcher

2:43 pm on Dec 12, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



No problem, although I can`t see that line making any difference. :P

dc

chhayrithy

2:49 pm on Dec 12, 2005 (gmt 0)

10+ Year Member



i think it is because i referenced the variable here:

if(mysql_num_rows($result)<1){
echo "<font face=Arial size=+0><b>No
Results!</b></font><br>";
}

anyway, now working on making the display look a little better or more readible. again, thanks for the replies and the help!

dreamcatcher

2:56 pm on Dec 12, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Glad you got it sorted out.

dc