Page 1 of 1

need some help with mysql

Posted: Sun Jul 30, 2006 3:29 pm
by darkangel2001lv
Everah | Please use

Code: Select all

,

Code: Select all

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

Code: Select all

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.

Everah | Please use

Code: Select all

,

Code: Select all

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]

Posted: Sun Jul 30, 2006 3:42 pm
by RobertGonzalez
Your code is wrong. Try this...

Code: Select all

<?php
php: 
define('DB_USER', 'user');
define('DB_PASSWORD', 'pass');
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. 
    }
}
?>

Still getting errors

Posted: Sun Jul 30, 2006 10:06 pm
by darkangel2001lv
feyd | Please use

Code: Select all

,

Code: Select all

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

Code: Select all

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



Have also tryed every this

Code: Select all

<?php 
 php:
define('DB_USER', '*****'); 
define('DB_PASSWORD', '*******'); 
define('DB_HOST', 'mysql147.secureserver.net'); 
define('DB_NAME', 'marvinos'); 

if ($dbc = mysql_connect (DB_mysq147.secureserver.net, DB_*****, DB_******)) { 
    if (!mysql_select_db(DB_marvinos)) { // If it can't select the database. 
}

And still nothing
it for some reason stops at DB_mysql147. and does not complete the full string of DB_mysql147.secureserver.net


here is the error i get

Code: Select all

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

feyd | Please use

Code: Select all

,

Code: Select all

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]

Posted: Sun Jul 30, 2006 10:12 pm
by feyd
You may want to sprinkle in some more mysql_error() outputs, say if mysql_connect() fails.

Posted: Sun Jul 30, 2006 10:21 pm
by darkangel2001lv
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.

Posted: Sun Jul 30, 2006 11:35 pm
by RobertGonzalez
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...

Code: Select all

<?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>';
}
?>

Posted: Sun Jul 30, 2006 11:42 pm
by darkangel2001lv
feyd | Please use

Code: Select all

,

Code: Select all

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:

Code: Select all

<?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>'; 
} 
?>

Code: Select all

We are connected!
We are in!

Fatal error: Call to undefined function: escape_data() in /home/content/m/a/r/marvinospizza/html/register.php on line 17
that is what i got in broswer


feyd | Please use

Code: Select all

,

Code: Select all

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]

Posted: Mon Jul 31, 2006 12:15 am
by feyd
darkangel2001lv, we are quite serious about using the syntax highlighting systems we've supplied. Please read the relating topics.

Posted: Mon Jul 31, 2006 12:20 am
by RobertGonzalez
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.