Jump to content

PHP issues in job scheduler


Go to solution Solved by kicken,

Recommended Posts

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 by Dark-Hawk
Link to comment
https://forums.phpfreaks.com/topic/281172-php-issues-in-job-scheduler/
Share on other sites

$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?

  • Solution

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 <?

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 :)

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.