griffen
06-05-2001, 12:40 PM
I have a php script below, but it keeps coming up with a parse error. Is that a problem with MySql or is it an error in the script?
When I get rid of the lower section of the PHP, it comes up with an error saying "Probelm connecting to the database"
Any ideas would be much appreciated.
James.
<HTML>
<HEAD><TITLE> Our List of Jokes
</TITLE>
<HEAD>
<BODY>
<?php // Connect to the database server
$dbcnx = @mysql_connect("localhost", "root", "******");
if (!$dbcnx) {
echo( "<P>Unable to connect to the " . "database server at this time.</P>" );
exit(); }
// Select the jokes database
if (! @mysql_select_db("jokes") ) {
echo( "<P>Unable to locate the joke " . "database at this time.</P>" );
exit();
}
?>
<P> Here are all the jokes in our database: </P>
<BLOCKQUOTE>
<?php
// Request the text of all the jokes
$result = mysql_query(
"SELECT JokeText FROM Jokes");
if (!$result) {
echo("<P>Error performing query: " .
mysql_error() . "</P>");
exit();
}
// Display the text of each joke in a paragraph
while ( $row = mysql_fetch_array($result) )
{
echo("<P>" . $row["JokeText"] . "</P>");
}
?>
</BLOCKQUOTE>
</BODY>
</HTML>
When I get rid of the lower section of the PHP, it comes up with an error saying "Probelm connecting to the database"
Any ideas would be much appreciated.
James.
<HTML>
<HEAD><TITLE> Our List of Jokes
</TITLE>
<HEAD>
<BODY>
<?php // Connect to the database server
$dbcnx = @mysql_connect("localhost", "root", "******");
if (!$dbcnx) {
echo( "<P>Unable to connect to the " . "database server at this time.</P>" );
exit(); }
// Select the jokes database
if (! @mysql_select_db("jokes") ) {
echo( "<P>Unable to locate the joke " . "database at this time.</P>" );
exit();
}
?>
<P> Here are all the jokes in our database: </P>
<BLOCKQUOTE>
<?php
// Request the text of all the jokes
$result = mysql_query(
"SELECT JokeText FROM Jokes");
if (!$result) {
echo("<P>Error performing query: " .
mysql_error() . "</P>");
exit();
}
// Display the text of each joke in a paragraph
while ( $row = mysql_fetch_array($result) )
{
echo("<P>" . $row["JokeText"] . "</P>");
}
?>
</BLOCKQUOTE>
</BODY>
</HTML>