Jump to content

[SOLVED] Query works in php my admin but not in php??


MadnessRed

Recommended Posts

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.

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.