Jump to content


Photo

need help with some code... Beginner!!


  • Please log in to reply
4 replies to this topic

#1 fwbbetsy

fwbbetsy
  • Members
  • PipPip
  • Member
  • 17 posts

Posted 05 September 2006 - 06:51 PM

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.emeraldco...sttraffic.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

#2 Stevis2002

Stevis2002
  • Members
  • PipPipPip
  • Advanced Member
  • 98 posts

Posted 05 September 2006 - 06:55 PM

$data = mysql_query("SELECT * FROM "user")

should be
$data = mysql_query("SELECT * FROM user)

I think.

#3 ober

ober
  • Staff Alumni
  • Advanced Member
  • 5,337 posts
  • LocationEast Coast, USA

Posted 05 September 2006 - 06:55 PM

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

Info: PHP Manual


#4 fwbbetsy

fwbbetsy
  • Members
  • PipPip
  • Member
  • 17 posts

Posted 05 September 2006 - 07:01 PM

I changed it:

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


$site1="http://www.emeraldco...sttraffic.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

#5 Stevis2002

Stevis2002
  • Members
  • PipPipPip
  • Advanced Member
  • 98 posts

Posted 05 September 2006 - 07:05 PM

Close the quotes..

$data = mysql_query("SELECT * FROM user)

to

$data = mysql_query("SELECT * FROM user")





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users