Jump to content

Passing Parameter through PHP > .SQL File


Swarfega

Recommended Posts

Hello.

 

 

I am unsure if this is even possible, but I was wondering if there's any way to pass a parameter from a PHP file when Running a .SQL File using shell_exec?

 

Something like

 

 

$PassParameter = "Test";
$cmd = "mysql -uName -pHidden -h hostIP -D dBName  $PassParameter < script/path/here";

$out = shell_exec($cmd . '/file.sql');

 

And let's say the SQL file is something like

 

 

INSERT INTO test VALUES('1', '2', '@PASSED-PARAMETER@');

 

Reason I need to pass a parameter to an .SQL File before running it, is because using PHP to insert into a table that's using a Blob column (I have the Blobs Saved) does not work. It only inserts part of the Blob, and therefor I cannot use that method, but running an .SQL File inserts the entirety of the Blob, and can therefor be used, if I can pass a parameter.

 

 

Any ideas?

Link to comment
https://forums.phpfreaks.com/topic/275380-passing-parameter-through-php-sql-file/
Share on other sites

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.