starrylitgal Posted March 4, 2009 Share Posted March 4, 2009 hi! i m having problem executing two queries together through my PHP code. Following is the code: $q1="CREATE TABLE `db`.`tb1`(`col1` tinyint(12),`col2` varchar(12)); CREATE TABLE `db`.`tb2` (`col1` int(12),`col2` varchar(12))"; mysql_query($q1) or die(mysql_error()); Is there nething wrong? This query is working properly when executed using phpmyadmin.... it always shows the following 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 'CREATE TABLE `db`.`tb2` at line 2' i tried to run it individually i.e. create these 2 tables (thru php code) separately like this : mysql_query($q1); mysql_query($q2); [$q2 being the second create table statement] and it successfully executed... but im not able to do it simultaneously in one query....wht is wrong??? i m not willing to run it separately coz i hav almost 28 queries to run and it wud mean running 28 queries separately....it wud be a long code...n as per my requirement i hav to chk its status of success for other operations...so.. plz does ne1 hav ne solution to this problem..! thnx! Quote Link to comment https://forums.phpfreaks.com/topic/147938-solved-execution-of-simultaneous-mysql-query-using-php/ Share on other sites More sharing options...
PFMaBiSmAd Posted March 4, 2009 Share Posted March 4, 2009 From the php manual - mysql_query() sends a unique query (multiple queries are not supported) to the currently active database on the server that's associated with the specified link_identifier . Quote Link to comment https://forums.phpfreaks.com/topic/147938-solved-execution-of-simultaneous-mysql-query-using-php/#findComment-776423 Share on other sites More sharing options...
starrylitgal Posted March 4, 2009 Author Share Posted March 4, 2009 ok..thnx... but then how do i solve this problem?? is there any other function which accepts multiple queries and executes them? Quote Link to comment https://forums.phpfreaks.com/topic/147938-solved-execution-of-simultaneous-mysql-query-using-php/#findComment-776432 Share on other sites More sharing options...
fenway Posted March 4, 2009 Share Posted March 4, 2009 ok..thnx... but then how do i solve this problem?? is there any other function which accepts any multiple queries? Why do you need such a function? Simply split the string to parts and run a for loop.... Quote Link to comment https://forums.phpfreaks.com/topic/147938-solved-execution-of-simultaneous-mysql-query-using-php/#findComment-776438 Share on other sites More sharing options...
starrylitgal Posted March 4, 2009 Author Share Posted March 4, 2009 hey thnx... i'll try that... thnx again! Quote Link to comment https://forums.phpfreaks.com/topic/147938-solved-execution-of-simultaneous-mysql-query-using-php/#findComment-776445 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.