Frank100 Posted May 27, 2007 Share Posted May 27, 2007 Hi, when I try to create 2 tables through a .php file like this it doesn’t work. Can somebody give me a hint ? It’s only the 2 querys which make problems, the rest of the file (not shown here) works … when I use just 1 query the .php file works fine and creates the desired table. Regards, Frank $query = " CREATE TABLE company ( company_id INT(10) unsigned NOT NULL auto_increment primary key , company_registerdate TIMESTAMP NOT NULL ) ENGINE = innodb"; $query = " CREATE TABLE lessor ( lessor_id INT(10) unsigned NOT NULL auto_increment primary key , lessor_registerdate TIMESTAMP NOT NULL , ) ENGINE = innodb"; Quote Link to comment https://forums.phpfreaks.com/topic/53117-problem-getting-2-queries-to-work-together/ Share on other sites More sharing options...
AndyB Posted May 27, 2007 Share Posted May 27, 2007 lessor_registerdate TIMESTAMP NOT NULL , Remove that final comma ... and execute each query separately of course. Quote Link to comment https://forums.phpfreaks.com/topic/53117-problem-getting-2-queries-to-work-together/#findComment-262409 Share on other sites More sharing options...
Frank100 Posted May 27, 2007 Author Share Posted May 27, 2007 Hi + thx for reply, sure, the comma has to go but how do I execute the queries separately in one p.p file ? Quote Link to comment https://forums.phpfreaks.com/topic/53117-problem-getting-2-queries-to-work-together/#findComment-262743 Share on other sites More sharing options...
AndyB Posted May 27, 2007 Share Posted May 27, 2007 // establish connection to database, select database, then ... $query = ".... first query ..."; $result = mysql_query($query); // execute first query $query = ".... second query ..."; $result = mysql_query($query); // execute second query ... Quote Link to comment https://forums.phpfreaks.com/topic/53117-problem-getting-2-queries-to-work-together/#findComment-262772 Share on other sites More sharing options...
Frank100 Posted May 29, 2007 Author Share Posted May 29, 2007 Hi Andy, thx again ! I've tried it out but it seems that I still make a mistake ... no tables are created. Here's my whole .php file. Regards, Frank <?php /* connect database */ $link = mysqli_connect("localhost", "root", "abc", "test"); /* check connection */ if (!$link) { printf("Connect failed: %s\n", mysqli_connect_error()); exit(); } // establish connection to database, select database, then ... $query = " CREATE TABLE placesx ( place_id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY , place_picture_01 VARCHAR(30) NOT NULL , place_picture_02 VARCHAR(30) NOT NULL ) ENGINE = innodb"; $result = mysql_query($query); // execute first query $query = " CREATE TABLE renterx ( renter_id INT(10) unsigned NOT NULL auto_increment primary key , renter_first_name VARCHAR(30) NOT NULL , renter_last_name VARCHAR(30) NOT NULL ) ENGINE = innodb"; $result = mysql_query($query); // execute second query ... /* check query */ if (mysqli_query($link, $query)=== TRUE) { printf("Table successfully created.\n"); } /* disconnect database */ mysqli_close($link); ?> Quote Link to comment https://forums.phpfreaks.com/topic/53117-problem-getting-2-queries-to-work-together/#findComment-263730 Share on other sites More sharing options...
Frank100 Posted May 29, 2007 Author Share Posted May 29, 2007 have tried it again in different variations but have not enough knoledge to find out why it doesn't work ... does somebody know ? Regards, Frank Quote Link to comment https://forums.phpfreaks.com/topic/53117-problem-getting-2-queries-to-work-together/#findComment-263970 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.