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

后端 未结 5 1071
失恋的感觉
失恋的感觉 2021-01-24 05:07

basically, I have 3 tables; users and projects, then I have \'users_projects\' to allow the one-to-many formation. When a user adds a project, I need the project information st

5条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-24 05:29

    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.

提交回复
热议问题