Neptunus Maris Posted May 12, 2008 Share Posted May 12, 2008 Is this correct? <?php mysql_query("SOURCE file.sql"); ?> Is that correct to run a *.sql file on your server through PHP? Thanks, Neptune Link to comment https://forums.phpfreaks.com/topic/105325-running-sql-with-php/ Share on other sites More sharing options...
DarkWater Posted May 12, 2008 Share Posted May 12, 2008 Why don't you try it yourself? =P Link to comment https://forums.phpfreaks.com/topic/105325-running-sql-with-php/#findComment-539406 Share on other sites More sharing options...
Neptunus Maris Posted May 12, 2008 Author Share Posted May 12, 2008 Why don't you try it yourself? =P Damn...lol Link to comment https://forums.phpfreaks.com/topic/105325-running-sql-with-php/#findComment-539438 Share on other sites More sharing options...
DarkWater Posted May 12, 2008 Share Posted May 12, 2008 It IS the correct way to do it, but you really could have tried it yourself. =P Link to comment https://forums.phpfreaks.com/topic/105325-running-sql-with-php/#findComment-539444 Share on other sites More sharing options...
Barand Posted May 12, 2008 Share Posted May 12, 2008 Any idea what versions of PHP/MySQL you need for that? I can't get it to work. <?php mysql_query ('SOURCE mytest.sql') or die(mysql_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 'SOURCE mytest.sql' at line 1 Link to comment https://forums.phpfreaks.com/topic/105325-running-sql-with-php/#findComment-539495 Share on other sites More sharing options...
cheechm Posted May 12, 2008 Share Posted May 12, 2008 <?php mysql_query ('LOAD DATA INFILE mytest.sql') or die(mysql_error()); ?> Link to comment https://forums.phpfreaks.com/topic/105325-running-sql-with-php/#findComment-539499 Share on other sites More sharing options...
Barand Posted May 12, 2008 Share Posted May 12, 2008 This worked <?php exec ('mysql < mytest.sql') ; ?> Link to comment https://forums.phpfreaks.com/topic/105325-running-sql-with-php/#findComment-539520 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.