Forum Moderators: coopster
can anyone tell me what this means
in this script
<?php
$host = 'localhost';
$user = '#*$!#*$!';
$pass = '#*$!#*$!x';
mysql_connect($host, $user, $pass);
mysql_select_db('$user');
$result = mysql_query("SELECT * FROM books");
if(!$result) die("Query Failed.");
while($row = mysql_fetch_row($result)) {
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head>
<meta http-equiv="content-type"
content="text/html; charset=iso-8859-1" />
<title>first mysql php action</title>
</head>
<body>
<?php echo "$result"
?>
</body>
</html>
From what I see here, you do not have a semicolon at the end of the following line:
<?php echo "$result"
?>
And as I see it now, you are not closing your while loop with a closing parenthesis (}).
Also, aside from the error you are receiving, it seems that you aren't properly grabbing the information from the database correctly as you may have wanted. For more information on how to do this properly, please refer to the following thread listed in your library: [webmasterworld.com...]
Resource id #3
i would have thougth i would have got a list of titles
i am missing something here
see code
<?php
$host = 'localhost';
$user = 'vvvvvv';
$pass = '#*$!#*$!xx';
mysql_connect($host, $user, $pass);
mysql_select_db($user);
$result = mysql_query("SELECT title FROM books");
if(!$result) die("Query Failed.");
while($row = mysql_fetch_row($result)) {
/*
$row[0] now contains the first column of the current row,
index 1 is the second, etc.
*/
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head>
<meta http-equiv="content-type"
content="text/html; charset=iso-8859-1" />
<title>first mysql php action</title>
</head>
<body>
<?php echo "$result"
?>
</body>
</html>
can any one suggest what is missing
<?php echo "$result"
?>
With the following:
<?php echo $row['title']; #echoes the title for each row retrieved ?>