Ok i have been trying to get this STUPID thing to work for a few hours and im seriously p off you have no idea how i feel~!!!!! :mad: :mad: :mad:
This is code exactly from the book im studying and it will not insert anything!
<html>
<head>
<title>Book-O-Rama - New Book Entry</title>
</head>
<body>
<h1>Book-O-Rama - New Book Entry</h1>
<form action="insert_book.php" method="post">
<table border="0">
<tr>
<td>ISBN</td>
<td><input type="text" name="isbn" maxlength="13" size="13"><br /></td>
</tr>
<tr>
<td>Author</td>
<td> <input type="text" name="author" maxlength="30" size="30"><br /></td>
</tr>
<tr>
<td>Title</td>
<td> <input type="text" name="title" maxlength="60" size="30"><br></td>
</tr>
<tr>
<td>Price $</td>
<td><input type="text" name="price" maxlength="7" size="7"><br /></td>
</tr>
<tr>
<td colspan="2"><input type="submit" value="Register"></td>
</tr>
</table>
</form>
</body>
</html>
<html>
<head>
<title>Book-O-Rama Book Entry Results</title>
</head>
<body>
<h1>Book-O-Rama Book Entry Results</h1>
<?php
// create short variable names
$isbn=$_POST['isbn'];
$author=$_POST['author'];
$title=$_POST['title'];
$price=$_POST['price'];
if (!$isbn || !$author || !$title || !$price)
{
echo 'You have not entered all the required details.<br />'
.'Please go back and try again.';
exit;
}
$isbn = addslashes($isbn);
$author = addslashes($author);
$title = addslashes($title);
$price = doubleval($price);
@ $db = mysql_pconnect('localhost', 'ryan', 'xxxxxxxx');
if (!$db)
{
echo 'Error: Could not connect to database. Please try again later.';
exit;
}
mysql_select_db('books');
$query = "insert into books values
('".$isbn."', '".$author."', '".$title."', '".$price."')";
$result = mysql_query($query);
if ($result)
echo mysql_affected_rows().' book inserted into database.';
?>
</body>
</html>
when i submit it does not echo mysql_affected_rows().' book inserted into database.';
it only displays Book-O-Rama Book Entry Results
It successfuly connects to database (password is correct), if i enter wrong password it says could not connect *...
Heres bookorama is correct db name
here is structure of bookorama db
mysql> describe books
-> ;
+--------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------+-------------+------+-----+---------+-------+
| isbn | varchar(13) | | PRI | | |
| author | varchar(30) | YES | | NULL | |
| title | varchar(60) | YES | | NULL | |
| price | float(4,2) | YES | | NULL | |
| cars | varchar(20) | YES | | NULL | |
+--------+-------------+------+-----+---------+-------+
5 rows in set (0.01 sec)