PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Can some please help me out i use this very same script on my other site and work with out flaw the only change is the DB_HOST this is the host name given i me by my hosting service
mysql147.secureserver.net
i have tryed typing in 'http://mysql147.secureserver.net'
'http://www.mysql147.secureserver.net'
so please can someone help
heres the code used
DEFINE ('DB_USER', 'user');
DEFINE ('DB_PASSWORD', 'pass');
DEFINE ('DB_HOST', 'mysql147.secureserver.net'); <----------------------------line 12
DEFINE ('DB_NAME', 'marvinos');
if ($dbc = mysql_connect (DB_mysql147.secureserver.net, DB_********, DB_****)) {
if (!mysql_select_db (DB_marvinos)) { // If it can't select the database.
user = username i use to login pass= password that i use to login
this is the error message i get and its got me stumped i use this same setup for my other site and works
An error occurred in script '/home/content/m/a/r/marvinospizza/html/includes/mysql_connect.php' on line 12:
Use of undefined constant DB_mysql147 - assumed 'DB_mysql147'
Date/Time: 7-30-2006 03:46:09
Everah | Removed potentially sensitive information from the original post.
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
i have used the code as you have it however still getting errors it is like it is getting confussed with the Host_Name here is the complete code Edited of course
<?php
php:
define('DB_USER', '*****');
define('DB_PASSWORD', '*******');
define('DB_HOST', 'mysql147.secureserver.net');
define('DB_NAME', 'marvinos');
if ($dbc = mysql_connect (DB_HOST, DB_USER, DB_PASSWORD)) {
if (!mysql_select_db(DB_NAME)) { // If it can't select the database.
}
// 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.
// 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.
?>
An error occurred in script '/home/content/m/a/r/marvinospizza/html/includes/mysql_connect.php' on line 8:
Use of undefined constant DB_mysql147 - assumed 'DB_mysql147'
Date/Time: 7-30-2006 19:46:20
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
OK But i do not get why this will not work i use the same code for my other website and it works fine the only changes are DB_USER DB_HOST. However the other sites DB_host is localhost this one is mysq147.secureserver.net but Why does it stop at mysql147 and then assumes can anyone explian this to me ? i would be very grateful this thing is begining to tick me off.
What Feyd is saying is that there is a possible error somewhere else. I am hosted on a GoDaddy server for one of my sites, and I have two databases. I changed from a mysqlXXX to a mysqlYYY and never experienced a problem, so there is a chance that there is a problem outside of PHP.
Run this code exactly as it is with no other code or includes and post back what was returned to the browser... Make sure you substitute your login credentials...
<?php
define('DB_USER', 'user'); // USE YOUR ACTUAL LOGIN NAME
define('DB_PASSWORD', 'pass'); // USE YOUR ACTUAL PASSWORD
define('DB_HOST', 'mysql147.secureserver.net');
define('DB_NAME', 'marvinos'); // VERIFY THIS IS YOUR DATABASE NAME
if (!$dbc = mysql_connect (DB_HOST, DB_USER, DB_PASSWORD)) {
die('<h1>Could not establish a connection to the database server ' . DB_HOST . ': ' . mysql_error() . '</h1>');
} else {
echo '<h1>We are connected!</h1>';
}
if (!mysql_select_db(DB_NAME)) {
die('<h1>Could not select database ' . DB_NAME . ': ' . mysql_error() . '</h1>');
} else {
echo '<h1>We are in!</h1>';
}
?>
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
php:
<?php
define('DB_USER', 'user'); // USE YOUR ACTUAL LOGIN NAME
define('DB_PASSWORD', 'pass'); // USE YOUR ACTUAL PASSWORD
define('DB_HOST', 'mysql147.secureserver.net');
define('DB_NAME', 'marvinos'); // VERIFY THIS IS YOUR DATABASE NAME
if (!$dbc = mysql_connect (DB_HOST, DB_USER, DB_PASSWORD)) {
die('<h1>Could not establish a connection to the database server ' . DB_HOST . ': ' . mysql_error() . '</h1>');
} else {
echo '<h1>We are connected!</h1>';
}
if (!mysql_select_db(DB_NAME)) {
die('<h1>Could not select database ' . DB_NAME . ': ' . mysql_error() . '</h1>');
} else {
echo '<h1>We are in!</h1>';
}
?>
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
OK, that means that you are connecting to the db server and getting a connection to your database. Now you just need to work on your custom function. You know, the one that is throwing your endefined function error...
And please use the PHP button when posting code. Highlight the text, then click the PHP button and you are in.