Web Hosting Talk







View Full Version : another php / mysql problem


xaero
11-22-2002, 08:16 PM
<?php
// Connect to the database
$db = mysql_connect("localhost","root","");
mysql_select_db (registered);
// Ask the database for the information from the links table
echo "<table border = '0' width = '100%' align='center'>";

$query = "SELECT * FROM 'people'";
$result = mysql_query($query);
while ($rows = mysql_fetch_row($result)) //<-- row 10 prob. line
// Here we make the script keep making new rows until all the links in our database are shown, this is called a loop
{
echo "<tr><td><A HREF='$rows[2]'>$rows[1]</A></td></tr>";
}
echo "</table>";
?>

Someone suggested that code, it eliminated my last problem however not when i call the page i get:

Parse error: parse error in /var/www/gaming/register/view.php on line 10

Anyone know what is wrong??
email me or reply here if you know what the problem is. Thanks alot.

sasha
11-22-2002, 08:21 PM
I can not see parse error in the code you posted, are you sure it is the right file?

xaero
11-23-2002, 03:42 AM
positive i am in the right one

goto
http://www.paulsation.com/gaming/register/view.php


all i want it to do is display the info in the mysql database the table is people and the fields are name email and site. is there anyother way go get my sql to dump all the entries into an html page??

wakkow
11-23-2002, 03:47 AM
You sure the query is returning anything?

MarkIL
11-23-2002, 06:51 AM
This code should work.

$db = mysql_connect('localhost','root','');
mysql_select_db('registered',$db);

print '<table border="0" width="100%" align="center">';
$query = "SELECT * FROM 'people'";
$result = mysql_query($query);

while ($rows=mysql_fetch_row($result))
printf('<tr><td><A HREF="%s">%s</A></td></tr>',$rows[2],$rows[1]);

print '</table>';

kunal
11-23-2002, 06:55 AM
hmm.. try this:
while ($rows = mysql_fetch_array($result)) //<-- row 10 prob. line

instead of :
while ($rows = mysql_fetch_row($result)) //<-- row 10 prob. line


kunal

matt2kjones
11-23-2002, 11:04 AM
That script looks incredibly simple,

do you want me to code a simular query that will do the exact same thing???

its a simple script, 5 mins, no charge.

if so just email me

admin@thedigitaldream.co.uk

hope u solve it

Matt

jtrovato
11-24-2002, 03:46 AM
still getting an invalid query...

Alan @ CIT
11-24-2002, 04:34 AM
Hi,

It looks to me like it's not getting any information back from the database, or isn't connectiong to the database.

After each mysql call, add a "or die(mysql_error());" to see if it's failing at the mysql_connect or mysql_select_db.

ie:

$db = mysql_connect("localhost","root","") or die (mysql_error());
mysql_select_db (registered) or die (mysql_error());

...

$result = mysql_query($query) or die(mysql_error());


Then see if any other error messages appear that might point you in the right direction.

Also (just a tip), you might want to think about adding a password to your mysql root account :-)

Thanks,
Alan.