Forums
This topic is locked
Newbie Problematic Insert
Posted 20 Feb 2002 18:20:41
1
has voted
20 Feb 2002 18:20:41 Matthew Thornhill posted:
Hi I'm new to php and not too hot on the language. Could someone please help me here... I would like to insert into the table "leader" column "team"....the value of "$teamname" where "$teamleader" = "staff_id"
$teamname and $teamleader are passed to the page in a form.
$sql2 = "INSERT INTO leader (team) WHERE staff_id=$teamleader
VALUES (\"$teamname\"";
$sql_result2 = mysql_query($sql2) or die ("Couldn't execute query 2"
if (!$sql_result) {
echo "<p>Couldn't add record 2!";
}
I'm not using phakt
Thanks in advance
Matt Thornhill
MaT
Replies
Replied 21 Feb 2002 22:05:17
21 Feb 2002 22:05:17 Bruno Mairlot replied:
Hi Mat,
the answer lies simply in your SQL query, it is not syntactically correct.
Use this : $sql2 = "INSERT INTO leader (team) <font color=red>VALUES ('$teamname')</font id=red> WHERE staff_id=$teamleader
The red part shows where you need to place the VALUES statement.
Bruno
--- Better to die trying, than never try at all ---
the answer lies simply in your SQL query, it is not syntactically correct.
Use this : $sql2 = "INSERT INTO leader (team) <font color=red>VALUES ('$teamname')</font id=red> WHERE staff_id=$teamleader
The red part shows where you need to place the VALUES statement.
Bruno
--- Better to die trying, than never try at all ---