Dark-Hawk Posted August 14, 2013 Share Posted August 14, 2013 (edited) This may be fairly odd architecture with how this script is ultimately being ran. I'm attempting to run a PHP script through an Enterprise job scheduler client on Windows, with an Agent on Fedora Linux. I have Apache/PHP/MySQL configured properly. I was originally having issues determining the path to place the config file on Fedora but determined it needed to be placed in /usr/share/php. The issue I'm having however, is my script is just printing the include file information in the script, rather than simply utilizing the variables within it for the MySQL DB. So the config.php file is fairly straight forward and just contains: <? $host = "0.0.0.0"; $username = "root"; $password = "*****"; $db = "processid"; ?> The script itself is: <?include '/usr/share/php/config.php'; $con = mysqli_connect('$host','$username','$password','$db'); // Check connectionif (mysqli_connect_errno()){ echo "Failed to connect to MySQL: " . mysqli_connect_error();} for($x = 0; $x < 15; $x++) {mysqli_query($con,"INSERT INTO idnumbers (ID)VALUES ('$x')");} mysqli_close($con);?> The output from my job scheduler is: <? $host = "0.0.0.0"; $username = "root"; $password = "****"; db = "processid"; ?> PHP Warning: mysqli_connect(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /root/.jams/job/07/cd0400-9b56-4409-a49b-52dc5b425016 on line 5 PHP Warning: mysqli_connect(): (HY000/2002): php_network_getaddresses: getaddrinfo failed: Name or service not known in /root/.jams/job/07/cd0400-9b56-4409-a49b-52dc5b425016 on line 5 Failed to connect to MySQL: php_network_getaddresses: getaddrinfo failed: Name or service not knownPHP Warning: mysqli_query() expects parameter 1 to be mysqli, boolean given in /root/.jams/job/07/cd0400-9b56-4409-a49b-52dc5b425016 on line 15 PHP Warning: mysqli_query() expects parameter 1 to be mysqli, boolean given in /root/.jams/job/07/cd0400-9b56-4409-a49b-52dc5b425016 on line 15 PHP Warning: mysqli_query() expects parameter 1 to be mysqli, boolean given in /root/.jams/job/07/cd0400-9b56-4409-a49b-52dc5b425016 on line 15 PHP Warning: mysqli_query() expects parameter 1 to be mysqli, boolean given in /root/.jams/job/07/cd0400-9b56-4409-a49b-52dc5b425016 on line 15 PHP Warning: mysqli_query() expects parameter 1 to be mysqli, boolean given in /root/.jams/job/07/cd0400-9b56-4409-a49b-52dc5b425016 on line 15 PHP Warning: mysqli_query() expects parameter 1 to be mysqli, boolean given in /root/.jams/job/07/cd0400-9b56-4409-a49b-52dc5b425016 on line 15 PHP Warning: mysqli_query() expects parameter 1 to be mysqli, boolean given in /root/.jams/job/07/cd0400-9b56-4409-a49b-52dc5b425016 on line 15 PHP Warning: mysqli_query() expects parameter 1 to be mysqli, boolean given in /root/.jams/job/07/cd0400-9b56-4409-a49b-52dc5b425016 on line 15 PHP Warning: mysqli_query() expects parameter 1 to be mysqli, boolean given in /root/.jams/job/07/cd0400-9b56-4409-a49b-52dc5b425016 on line 15 PHP Warning: mysqli_query() expects parameter 1 to be mysqli, boolean given in /root/.jams/job/07/cd0400-9b56-4409-a49b-52dc5b425016 on line 15 PHP Warning: mysqli_query() expects parameter 1 to be mysqli, boolean given in /root/.jams/job/07/cd0400-9b56-4409-a49b-52dc5b425016 on line 15 PHP Warning: mysqli_query() expects parameter 1 to be mysqli, boolean given in /root/.jams/job/07/cd0400-9b56-4409-a49b-52dc5b425016 on line 15 PHP Warning: mysqli_query() expects parameter 1 to be mysqli, boolean given in /root/.jams/job/07/cd0400-9b56-4409-a49b-52dc5b425016 on line 15 PHP Warning: mysqli_query() expects parameter 1 to be mysqli, boolean given in /root/.jams/job/07/cd0400-9b56-4409-a49b-52dc5b425016 on line 15 PHP Warning: mysqli_query() expects parameter 1 to be mysqli, boolean given in /root/.jams/job/07/cd0400-9b56-4409-a49b-52dc5b425016 on line 15 PHP Warning: mysqli_close() expects parameter 1 to be mysqli, boolean given in /root/.jams/job/07/cd0400-9b56-4409-a49b-52dc5b425016 on line 18 Edited August 14, 2013 by Dark-Hawk Quote Link to comment https://forums.phpfreaks.com/topic/281172-php-issues-in-job-scheduler/ Share on other sites More sharing options...
requinix Posted August 14, 2013 Share Posted August 14, 2013 $con = mysqli_connect('$host','$username','$password','$db');Variables do not work in single-quoted strings. Do away with the quotes entirely. Quote Link to comment https://forums.phpfreaks.com/topic/281172-php-issues-in-job-scheduler/#findComment-1445049 Share on other sites More sharing options...
Dark-Hawk Posted August 14, 2013 Author Share Posted August 14, 2013 $con = mysqli_connect('$host','$username','$password','$db');Variables do not work in single-quoted strings. Do away with the quotes entirely. Good catch, thanks! Been a while since I've worked in PHP :/. Any insight as to why it is simply grabbing the contents of the included file as opposed to simply utilizing the variables? Quote Link to comment https://forums.phpfreaks.com/topic/281172-php-issues-in-job-scheduler/#findComment-1445050 Share on other sites More sharing options...
Solution kicken Posted August 14, 2013 Solution Share Posted August 14, 2013 My first guess would have been that short tags is disabled, but if your main script is also using them and it works fine, then that seems unlikely. Regardless, you should not be using them anyway. Use full <?php tags, not <? Quote Link to comment https://forums.phpfreaks.com/topic/281172-php-issues-in-job-scheduler/#findComment-1445052 Share on other sites More sharing options...
Dark-Hawk Posted August 14, 2013 Author Share Posted August 14, 2013 My first guess would have been that short tags is disabled, but if your main script is also using them and it works fine, then that seems unlikely. Regardless, you should not be using them anyway. Use full <?php tags, not <? Nope that was it! Thanks a lot Quote Link to comment https://forums.phpfreaks.com/topic/281172-php-issues-in-job-scheduler/#findComment-1445055 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.