Jump to content

Archived

This topic is now archived and is closed to further replies.

fwbbetsy

need help with some code... Beginner!!

Recommended Posts

I am trying to get this code to work but keep getting errors:

<?
$hostnm = "localhost";
$usernm = "emeraldc_ustraff";
$pwd = "emeraldc_ustraff";
$dbName = "emeraldc_dbtraff";


$site1="http://www.emeraldcoasttraffic.com";

$data = mysql_query("SELECT * FROM "user")
or die(mysql_error());
Print "<table border cellpadding=3>";
while($info = mysql_fetch_array( $data ))
{
Print "<tr>";
Print "<th>Name:</th> <td>".$info['name'] . "</td> ";
Print "<th>Credits:</th> <td>".$info['credits'] . " </td></tr>";
}
Print "</table>";
?>

The error I get is:
Parse error: parse error, unexpected T_STRING in /home/emeraldc/public_html/test.php on line 10

Any help would be appricated.

thanks

Betsy

Share this post


Link to post
Share on other sites
[code]
$data = mysql_query("SELECT * FROM "user")
[/code]

should be
[code]
$data = mysql_query("SELECT * FROM user)
[/code]

I think.

Share this post


Link to post
Share on other sites
A few things:
1) don't put your table name in quotes: $data = mysql_query("SELECT * FROM user") or die(mysql_error());
2) print is all lowercase

Share this post


Link to post
Share on other sites
I changed it:

<?
$hostnm = "localhost";
$usernm = "emeraldc_ustraff";
$pwd = "emeraldc_ustraff";
$dbName = "emeraldc_dbtraff";


$site1="http://www.emeraldcoasttraffic.com";

$data = mysql_query("SELECT * FROM user)
or die(mysql_error());
print "<table border cellpadding=3>";
while($info = mysql_fetch_array( $data ))
{
print "<tr>";
print "<th>Name:</th> <td>".$info['name'] . "</td> ";
print "<th>Credits:</th> <td>".$info['credits'] . " </td></tr>";
}
print "</table>";
?>

still getting an error but a different one:


Parse error: parse error, unexpected T_STRING in /home/emeraldc/public_html/test.php on line 12

thanks

Betsy

Share this post


Link to post
Share on other sites
Close the quotes..

[code]$data = mysql_query("SELECT * FROM user)
[/code]

to

[code]$data = mysql_query("SELECT * FROM user")[/code]

Share this post


Link to post
Share on other sites

×

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.