Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.