ok .. I just wrote my first ever php script .. but it's showing a parser error in the IF statment ..
Parse error: parse error, unexpected T_IF in
c:\program files\apache group\apache\htdocs\scripts\addition.php on line 31
and here is my php code :
PHP Code:
<?php
/*first get all feilds values in here ..*/
$title=$HTTP_POST_VARS['title'];
$bookid=$HTTP_POST_VARS['bookID'];
$authf=$HTTP_POST_VARS['authf'];
$authl=$HTTP_POST_VARS['authl'];
$price=$HTTP_POST_VARS['price'];
/*now we Clean in the entries from spaces , to make
sure the DB don't get screwed up ..*/
$title=trim($title);
$bookid=trim($bookid);
$authf=trim($authf);
$authl=trim($authl);
$price=trim($price);
/*another cleaning process ,, but this time to make sure
no special chars would hurt the DB */
$title=addslashes($title);
$bookid=addslashes($bookid);
$authf=addslashes($authf);
$authl=addslashes($authl);
$price=addslashes($price);
/*now we should specify the MySQL connection info ..*/
$db_name="bookdb";
$server="localhost";
$db_user="saleh";
$db_pass="hidden"
/*check if user completed the form or not ..*/
if (!isset($title) || !isset($bookid) || !isset($authf) || !isset($authl) || !isset($price))
{
echo "Sorry but you did not complete all fields .. please go back and fill ALL fields";
}
/*now we will try to connect to MySQL database .*/
else
{
echo "now we are trying to connect to MySQL ..";
}
mysql_connect($server , $db_user , $db_pass)
or die("Could not connect: " . mysql_error());
print ("Connected successfully");
mysql_db_select($db_name);
mysql_query("INSERT INTO books (title, bookID, authF, authL, price)
VALUES ($title, $bookid, $authf, $authl, $price)");
$result=mysql_query("SELECT * FROM books", $db);
$record_total=mysql_num_rows($result);
echo "Total of books Record in the database is :" .$record_total .;
?>
the varibles values should be passed via form submittion .. the form is plain HTML ....
you know I love php but after this thing I started to hate it
