Jump to content

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


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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.