PHP script works on browser but not wget

I have bash -sctipt running 5 php scripts via wget. Every php file gets called, but in the last script I get this warning:

mysql_query (): The supplied argument is an invalid MySQL-Link resource in xyz.php, on line ABC

What's really weird is if I run the same script through the browser, the script runs fine, without any warnings.

This is my code next to ABC:

$sqlSTR="INSERT INTO accounts_cstm (id_c, mtk_categoriascompradas_c) VALUES ('". $arr[1] . "', '" . $arr[0] . "')
                    ON DUPLICATE KEY UPDATE mtk_categoriascompradas_c= concat(mtk_categoriascompradas_c, '^,^$arr[0]')";        

$ExecuteSQL = mysql_query ($sqlSTR, $DBConn) or
                die ($sqlSTR); //warning on this line - line ABC

      

My SQL is completely valid (if I run the query that outputs in the die statement it works fine), DBConn is connected to the database, and all other scripts work fine except that.

I really don't know what is causing this warning. Any help would be greatly appreciated.

thanks

0


a source to share


4 answers


Your problem is with your database connection ( $DBConn

). Take a look at this code. Paste in var_dump and try wgetting again.



+4


a source


Always use mysql_error()

when you see this error message. Then you will know the exact reason why the request was invalid.



+1


a source


Something definitely looks wrong with your last reference to $ arr [0] in the request - I think it should be this:

$sqlSTR="INSERT INTO accounts_cstm (id_c, mtk_categoriascompradas_c) VALUES ('". $arr[1] . "', '" . $arr[0] . "')
ON DUPLICATE KEY UPDATE mtk_categoriascompradas_c= concat(mtk_categoriascompradas_c, '^,^".$arr[0]."')";   

      

0


a source


Does the url you are calling with wget have an ampersand in it? If you do, make sure your shell doesn't interpret it assend process to background

0


a source







All Articles