Run MySQL INSERT Query multiple times (insert values into multiple tables)?

You simply forgot to execute the sql between each query. Add the mysql_query($sql, $connection) or die("MySQL Error: ". Mysql_error()) between each query and you are supposed to be fine b.t.

W (1) it always helpful to test with a console open with tail -f on the sql log (under var/log/mysql ) b.t.w.(2) You are having heavy security issues in your code b.t. W (3) You might want to consider using PDO/Mysqli and not the old mysql extension. B.t.

W (4) It would make your life simpler to use some kind of wrapper (a good class) to approach the DB and not do it directly everywhere in your code.

You simply forgot to execute the sql between each query. Add the mysql_query($sql, $connection) or die("MySQL Error: ". Mysql_error()); between each query and you are supposed to be fine.B.t.

W (1) it always helpful to test with a console open with tail -f on the sql log (under /var/log/mysql/ ) b.t.w.(2) You are having heavy security issues in your code. B.t. W (3) You might want to consider using PDO/Mysqli and not the old mysql extension.B.t.

W (4) It would make your life simpler to use some kind of wrapper (a good class) to approach the DB and not do it directly everywhere in your code.

I have updated the question to include all of the code – Yvonne Mar 15 '10 at 17:58 @Derek - I am sorry to inform you that although assumptions are the mother of all fuckups, Mine was correct. – Itay Moav Mar 15 '10 at 22:57.

If you're seeing things get inserted, but some of the data is blank then something might be blowing up before that and those variables would be blank.

Its only the project ID not being stored in usersprojects table, so close! – Yvonne Mar 15 '10 at 18:45.

I may be misunderstanding but are you putting header("Location: main. Php"); in the middle of you script?

No sorry I did have this for a split second when I was editing the example code above! That would bhave been quite embaressing :) – Yvonne Mar 15 '10 at 18:19.

$projectid=mysql_insert_id($connection); I called this after my first query, this will get the AutoIncrement value from your projects table and store it in $projectid, then the second query will use it. So after execution of my first query, I put the above code there, without changing anything else!

You seem to be trying to execute mysql_query() only once. You have two queries, so it needs to be used twice, once on each query: $sql = "INSERT INTO projects (projectid, projectname, projectdeadline, projectdetails) VALUES ('{$projectid}','{$projectname}','{$projectdeadline}','{$projectdetails}')"; $result = mysql_query($sql, $connection) or die("MySQL Error: ". Mysql_error()); $sql = "INSERT INTO usersprojects (userid, projectid) VALUES ('{$userid}','{$projectid}')"; $result = mysql_query($sql, $connection) or die("MySQL Error: ".

Mysql_error()); Alternatively, you could use mysqli_multi_query(), but that might require a significant rewrite of your code to use the mysqli interface.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions