knightrain
Programmer
I am new to PHP/MYSQL and am setting up/running Apache 2 as a development platform on my Win XP pc.
I have succeeded in running php scripts on Apache but when I attempt to connect to mySQL I don't receive any response whatsoever, not even a helpful error message.
I have attempted binding the address in my.ini to 127.0.0.1, and have moved the mysql_connect script various places within my "www" structure.
I understand that certain firewall applications on XP can be problematic. I feel that there is probably a simple fix that I'm overlooking; I'd like to find it before I start tampering with my protection software.
Here's what I'm running into. Running the following script produces only "point 3", which makes me believe that the script is bailing out around the _connect command:
<?php # mysql_connect.php
// This file contains the database access information.
// This file also establishes a connection to MySQL and selects the database.
// Set the database access information as constants.
DEFINE ('DB_USER', 'root');
DEFINE ('DB_PASSWORD', 'yosar');
DEFINE ('DB_HOST', 'localhost');
DEFINE ('DB_NAME', 'yosar');
echo 'point 3';
if ($dbc = mysql_connect (DB_HOST, DB_USER, DB_PASSWORD)) { // Make the connnection.
echo 'point 4';
if (!mysql_select_db (DB_NAME)) { // If it can't select the database.
echo 'point 1';
// Handle the error.
trigger_error("Could not select the database!\n<br />MySQL Error: " . mysql_error());
// Print a message to the user, include the footer, and kill the script.
include ('./includes/footer.html');
exit();
} // End of mysql_select_db IF.
} else { // If it couldn't connect to MySQL.
echo 'point 2';
// Print a message to the user, include the footer, and kill the script.
trigger_error("Could not connect to MySQL!\n<br />MySQL Error: " . mysql_error());
include ('./includes/footer.html');
exit();
} // End of $dbc IF.
echo 'point 6';
// Create a function for escaping the data.
function escape_data ($data) {
// Address Magic Quotes.
if (ini_get('magic_quotes_gpc')) {
$data = stripslashes($data);
}
// Check for mysql_real_escape_string() support.
if (function_exists('mysql_real_escape_string')) {
global $dbc; // Need the connection.
$data = mysql_real_escape_string (trim($data), $dbc);
} else {
$data = mysql_escape_string (trim($data));
}
// Return the escaped value.
return $data;
} // End of function.
?>
Any help would be....helpful.
Thanks.
I have succeeded in running php scripts on Apache but when I attempt to connect to mySQL I don't receive any response whatsoever, not even a helpful error message.
I have attempted binding the address in my.ini to 127.0.0.1, and have moved the mysql_connect script various places within my "www" structure.
I understand that certain firewall applications on XP can be problematic. I feel that there is probably a simple fix that I'm overlooking; I'd like to find it before I start tampering with my protection software.
Here's what I'm running into. Running the following script produces only "point 3", which makes me believe that the script is bailing out around the _connect command:
<?php # mysql_connect.php
// This file contains the database access information.
// This file also establishes a connection to MySQL and selects the database.
// Set the database access information as constants.
DEFINE ('DB_USER', 'root');
DEFINE ('DB_PASSWORD', 'yosar');
DEFINE ('DB_HOST', 'localhost');
DEFINE ('DB_NAME', 'yosar');
echo 'point 3';
if ($dbc = mysql_connect (DB_HOST, DB_USER, DB_PASSWORD)) { // Make the connnection.
echo 'point 4';
if (!mysql_select_db (DB_NAME)) { // If it can't select the database.
echo 'point 1';
// Handle the error.
trigger_error("Could not select the database!\n<br />MySQL Error: " . mysql_error());
// Print a message to the user, include the footer, and kill the script.
include ('./includes/footer.html');
exit();
} // End of mysql_select_db IF.
} else { // If it couldn't connect to MySQL.
echo 'point 2';
// Print a message to the user, include the footer, and kill the script.
trigger_error("Could not connect to MySQL!\n<br />MySQL Error: " . mysql_error());
include ('./includes/footer.html');
exit();
} // End of $dbc IF.
echo 'point 6';
// Create a function for escaping the data.
function escape_data ($data) {
// Address Magic Quotes.
if (ini_get('magic_quotes_gpc')) {
$data = stripslashes($data);
}
// Check for mysql_real_escape_string() support.
if (function_exists('mysql_real_escape_string')) {
global $dbc; // Need the connection.
$data = mysql_real_escape_string (trim($data), $dbc);
} else {
$data = mysql_escape_string (trim($data));
}
// Return the escaped value.
return $data;
} // End of function.
?>
Any help would be....helpful.
Thanks.