Jump to content

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

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.