Hi all!
I'm a new to PHP and I embarked on a making a small store. One part of this involves making a form to add new products, and tables for categories. But I am getting this error:
Parse error: syntax error, unexpected T_VARIABLE, expecting ',' or ';' on line 17
I don't find anything wrong with my code.
<?php
if ($_POST){
$adding = mysql_escape_string($_POST['add_category']);
echo "Adding ".$adding ." to products...<br />";
$mysql_connection = mysql_connect("host", "username", "password");
if (!$mysql_connection) die("<font color='red'><b>MySQL connection error, process halted!</b></font>");
if (!mysql_select_db("products", $mysql_connection)) die ("Unable to select database, process halted!");
$get_categories = mysql_query("SELECT * FROM categories");
echo 'Checking if category already exists...<br />';
while ($row = mysql_fetch_assoc($get_categories)){
$name = $row['category_name'];
if ($adding != $name){
echo "Category does not exist...<br />
Adding...<br />";
$add_categories = mysql_query("INSERT INTO categories VALUES ('', '$adding')");
echo "Successfully inserted into database...<br />"
$create_table = mysql_query(" CREATE TABLE `products`.`$adding` (
`item_#` VARCHAR( 9 ) NOT NULL ,
`name` VARCHAR( 1000 ) NOT NULL ,
`price` VARCHAR( 9 ) NOT NULL ,
`description` VARCHAR( 9999999 ) NOT NULL ,
`short_description` VARCHAR( 50000 ) NOT NULL ,
`image` VARCHAR( 9999999 ) NOT NULL
) ENGINE = MYISAM ;");
echo "Successfully created table...<br />";
} else {
echo " <font color='red'>Category exists, process halted...</font><br />
<a href='index.php?page=login'>Click here to return to the form.</a>";
};
}
}
?>
Thank you in advance!