Jump to content

[SOLVED] Mysql Error!!


shotos

Recommended Posts

hello,

i just finished writing a script that inserts inputted data into one table and also

adds a column to another table.

Now, inserting into the first table works perfectly but the alter command produces

this a this error:

 

You have an error in your SQL syntax; check the manual that corresponds to your

MySQL server version for the right syntax to use near 'Tita add car varchar(50)' at line 1

 

Today is my second day figuring out whats wrong.........am all worn out.

help is welcomed. This is the code snippet involved in writing into the database.

 

include_once('mysql.php');
	$title = $_SESSION['edit_title'];

	$db = &new Mysql();
	$num_items = count($items);
	$id = 0;
	do
	{
		$element = $id + 1;
		$alignment = $id + 2;
		$label = $id + 3;
		$add = "INSERT INTO $title(check_item, checklist_element, alignment, labels) VALUES('$items[$id]','$items[$element]','$items[$alignment]','$items[$label]')";
		$fill = mysql_query($add,$db->link) or die(mysql_error());

		$id = $id + 4;
	}while($id < $num_items);


	$it = 0;
	do
	{
		$input = $items[$it];
		$input = trim($input);
		$input = str_replace(" ","_",$input);
		//echo $input;
		$join = "alter table Element_$title add $input varchar(50)";
		$write = mysql_query($join,$db->link) or die(mysql_error());
		$it = $it + 4;
	}while($it < $num_items);

Link to comment
https://forums.phpfreaks.com/topic/119500-solved-mysql-error/
Share on other sites

this is the erroe message:

 

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server

version for the right syntax to use near 'Tita ADD COLUMN temperature varchar(50)' at line 1Query was:

ALTER TABLE Element_ Tita ADD COLUMN temperature varchar(50)

Link to comment
https://forums.phpfreaks.com/topic/119500-solved-mysql-error/#findComment-615646
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.