Hi Guys,
I'm not entirely new to php but I'm still learning a lot of the syntax and functions, so i'm still making stupid mistakes.
Basically im trying to edit my code so that i can insert information into different mysql tables dependant on a variable transerred from a form.
mysql_select_db("thejamez_linkcontrol");
if ($tbl == 'tooth');
{
$query = "INSERT INTO teeth (url, before, anchor, after) VALUES ('$url', '$before', '$anchor', '$after')";
$result = mysql_query($query);
echo mysql_insert_id();
if ($result)
echo "mysql_affected_rows()"." Inserted into DB.";
echo "Printing to see if it works - put into teeth $url : $anchor";
exit;}
else ($tbl == 'team2g');
{
$query = "INSERT INTO team2g (url, before, anchor, after) VALUES ('$url', '$before', '$anchor', '$after')";
$result = mysql_query($query);
echo mysql_insert_id();
if ($result)
echo "mysql_affected_rows()"." Inserted into DB.";
echo "Printing to see if it works - put into team2g $url : $anchor";
exit;}
The variable im trying to carry over is "$tbl" , and if it equals "tooth" i want it to insert into the "teeth" table, but if it equals "team2g" i want it to insert into the "team2g" table.
I'm obviously doing something wrong because when $tbl was equal to either variable it was only adding to teeth.
Anyone see an obvious error?