Jump to content
xisto Community
Eggie

SQL Doesn't Connect In PHP Script I made some code updates now the script is broken.

Recommended Posts

eggie.. Try this one. it should work. (remeber to change the passwor and stuff).

<?$con = mysql_connect('localhost','MySQL_Username','MySQL_Password');if (!$con)  {  die('Could not connect: ' . mysql_error());  }mysql_select_db('MySQL_DbName',$con);?>

Share this post


Link to post
Share on other sites

eggie.. Try this one. it should work. (remeber to change the passwor and stuff).

<?$con = mysql_connect('localhost','MySQL_Username','MySQL_Password');if (!$con)  {  die('Could not connect: ' . mysql_error());  }mysql_select_db('MySQL_DbName',$con);?>
Should i put that in "config.php" or?and i already posted few times that it does connect to database but something is wrong and it doesn't put information while registering....

Share this post


Link to post
Share on other sites

yes. Put my code:

<?$con = mysql_connect('localhost','MySQL_Username','MySQL_Password');if (!$con)  {  die('Could not connect: ' . mysql_error());  }mysql_select_db('MySQL_DbName',$con);?>
in config.php Instead of this

mysql_pconnect("localhost","eggie_Eggie","jajetic");mysql_select_db("eggie_Eggie");

Share this post


Link to post
Share on other sites

yes. Put my code:

<?$con = mysql_connect('localhost','MySQL_Username','MySQL_Password');if (!$con)  {  die('Could not connect: ' . mysql_error());  }mysql_select_db('MySQL_DbName',$con);?>
in config.php Instead of this

mysql_pconnect("localhost","eggie_Eggie","jajetic");mysql_select_db("eggie_Eggie");
ok..but i can't now...my girlfriend is here and she's pissed...i will post here if it solved the problem or it didn't and thank you for posting ;)
EDIT:i tried it and still nothing...i really don't know why....damn
Edited by Eggie (see edit history)

Share this post


Link to post
Share on other sites

Well, I'm not about to try and figure out what your script is or isn't doing but we can look at the most common causes!

First, you need to get you PHP info! If your host is using PHP 5, by default mysql is turned off and mysqli is required instead.

echo phpinfo();

Next, you should try and echo your queries as well so that you can see what the server sees.
change:
mysql_query("insert into players (user, email, pass, question, answer, class) values('$new_user','$new_email','$db_pass5', '$sec_question', '$sec_pass','$charclass')") or die("Could not register.. trouble with adding you to the players table.");
to:
$query = "insert into players (user, email, pass, question, answer, class) values('$new_user','$new_email','$db_pass5', '$sec_question', '$sec_pass','$charclass')";echo $query;	mysql_query($query;) or die("Could not register.. trouble with adding you to the players table.");
That'll make a mess of your pages but will show you if the query is not being built correctly. It is a good idea to actually run those queries manually in phpMyAdmin to be sure that they work.

The style in which your code is written makes it very difficult to debug! I also don't connect to my database the way you do and never use the persistant connection but if you haven't had trouble before, then I can't imagine that it is the trouble now.

vujsa

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | 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.