0

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!

5
Contributors
6
Replies
10
Views
6 Years
Discussion Span
Last Post by rotten69
1
echo "Successfully inserted into database...<br />"

needs a ; at the end.

Votes + Comments
0

echo " <font color='red'>Category exists, process halted...</font><br />
this one also has no semi-colon

0

echo " <font color='red'>Category exists, process halted...</font><br />
this one also has no semi-colon

perhaps you should read to the end of the line, 28 in the source
its not wrong, just badly formatted

Edited by almostbob: n/a

0

Line 16 needs a ;

it's OK. Sometimes, you write a bunch of lines and when you're trying to run them, you don't find an obvious mistake.But, having someone to look at your code helps a lot.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.