MadnessRed Posted October 13, 2009 Share Posted October 13, 2009 Firstly here is the bit of my code which runs the query. //Log $handle = @fopen("./install/sql.log", 'w'); fwrite($handle, $sql); fclose($handle); //Import @mysql_query($sql) or die('5 - '.mysql_error()); And i get the output 5 - 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 IF NOT EXISTS `table1` ( `id` bigint(20) unsigned NOT NULL auto' at line 22 Then if I open sql.log, copy and paste the code from there into php my admin. Your SQL query has been executed successfully I don't understand how phpMyAdmin is working code that php won't, when pma itself is php. The code is a set of tables exported from phpmyadmin. Any help would be great. Quote Link to comment https://forums.phpfreaks.com/topic/177578-solved-query-works-in-php-my-admin-but-not-in-php/ Share on other sites More sharing options...
johnsmith153 Posted October 13, 2009 Share Posted October 13, 2009 show us $sql Quote Link to comment https://forums.phpfreaks.com/topic/177578-solved-query-works-in-php-my-admin-but-not-in-php/#findComment-936291 Share on other sites More sharing options...
MadnessRed Posted October 13, 2009 Author Share Posted October 13, 2009 I have sorted it, mysql didn't like multiple queries. I exploded the string by ; and ran each query separately and its fine now. Thanks for the help though, and also are there any better ways of doing this as I know exploding by ; is crude. Quote Link to comment https://forums.phpfreaks.com/topic/177578-solved-query-works-in-php-my-admin-but-not-in-php/#findComment-936312 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.