need another set of eyes for this...
Posted: Tue Nov 29, 2005 12:35 pm
I am still quite a newbie here. I am working on a very simple PHP/MySQL app to catalog my CDs. This is for a school project. Anyway, I am having a couple of problems with this that I haven't been able to figure out. I will post the first one here...
I am getting a PARSE ERROR UNEXPECTED ')' in LINE 14 when I try to use this add info to the database. Is there a better way that I should have done this? I tried commenting out that block, but then I get other errors.
I am getting a PARSE ERROR UNEXPECTED ')' in LINE 14 when I try to use this add info to the database. Is there a better way that I should have done this? I tried commenting out that block, but then I get other errors.
Code: Select all
<html>
<head>
<title>CD Catalog</title>
</head>
<body>
<h1>CD Catalog Entry Results</h1>
<?php
// create short variable names
$title=$_POST['title'];
$genre=$_POST['genre'];
$band=$_POST['band'];
if (!$title || !$genre || !$band ||)
{
echo 'You have not entered all the required details.<br />'
.'Please go back and try again.';
exit;
}
if (!get_magic_quotes_gpc())
{
$title = addslashes($title);
$genre = addslashes($genre);
$band = addslashes($band);
}
@ $db = new mysqli('localhost', '*****', '*****', 'cdcatalog');
if (mysqli_connect_errno())
{
echo 'Error: Could not connect to database. Please try again later.';
exit;
}
$query = "insert into cds values
('".$title."', '".$genre."', '".$band."')";
$result = $db->query($query);
if ($result)
echo $db->affected_rows.' data inserted into database.';
$db->close();
?>
</body>
</html>