Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-05-2013, 10:56 PM   PM User | #1
amcf1992
Regular Coder

 
Join Date: Jul 2011
Posts: 114
Thanks: 7
Thanked 0 Times in 0 Posts
amcf1992 is an unknown quantity at this point
PHP or die mysql error

Thanks in advanced for the help, anyways i'm coding a register script
but im not seeing the mysql_error message, the page when executed doesn't show the actual mysql error ( like it should), it just says mysql_error()


database/config.php

PHP Code:
<?php
$mysql_hostname 
"localhost";
$mysql_user "root";
$mysql_password "";
$mysql_database "test";
$db mysql_connect($mysql_hostname$mysql_user$mysql_password)
or die(
"mysql_error()");
mysql_select_db($mysql_database$db) or die("mysql_error()");
?>
Registration.php
PHP Code:
<?php
include("database/config.php");
if(
$_SERVER["REQUEST_METHOD"] == "POST")
{
// username and password sent from Form
$username=mysql_real_escape_string($_POST['username']);
$password=mysql_real_escape_string($_POST['password']);
$password=md5($password); // Encrypted Password
$email=mysql_real_escape_string($_POST['email']);
$date date();



$sql="Insert into test (id, username, password, email, date ) values('','$username','$password','$email','$date');";
$result=mysql_query($sql);
echo 
"You have successfully registered, you may login now. ";
}
?>
<form action="registration.php" method="post">


Email: <input type="text" name="email"/>

Username: <input type="text" name="username"/>
<br />
Password: <input type="password" name="password"/>
<br/>
<input type="submit" value=" Submit "/>
<br />
</form>
amcf1992 is offline   Reply With Quote
Old 01-05-2013, 11:25 PM   PM User | #2
LearningCoder
Regular Coder

 
LearningCoder's Avatar
 
Join Date: Jan 2011
Location: The Pleiades
Posts: 849
Thanks: 67
Thanked 28 Times in 28 Posts
LearningCoder is an unknown quantity at this point
It's echo'ing that because you are echo'ing the STRING mysql_error() rather than the actual return value of that function.

Try this:
PHP Code:
die("Error: ".mysql_error()); 
Hope it helps,

Kind regards,

LC.

Last edited by LearningCoder; 01-05-2013 at 11:42 PM..
LearningCoder is offline   Reply With Quote
Old 01-07-2013, 05:04 AM   PM User | #3
amcf1992
Regular Coder

 
Join Date: Jul 2011
Posts: 114
Thanks: 7
Thanked 0 Times in 0 Posts
amcf1992 is an unknown quantity at this point
Thank you, i was able to fix the issue once the mysql error problem was fixed, thanks for your help. I feel stupid, haha.
amcf1992 is offline   Reply With Quote
Reply

Bookmarks

Tags
mysql error, php, register

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 04:49 PM.


Advertisement
Log in to turn off these ads.