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!

Member Avatar for diafol
echo "Successfully inserted into database...<br />"

needs a ; at the end.

commented: yes +5

Ok, thanks! I feel stupid for making such a simple mistake...

Member Avatar for diafol

OK, no prob. Mark as solved.

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

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

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.