CodingForums.com

CodingForums.com (http://www.codingforums.com/index.php)
-   PHP (http://www.codingforums.com/forumdisplay.php?f=6)
-   -   PHP or die mysql error (http://www.codingforums.com/showthread.php?t=285343)

amcf1992 01-05-2013 10:56 PM

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>


LearningCoder 01-05-2013 11:25 PM

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.

amcf1992 01-07-2013 05:04 AM

Thank you, i was able to fix the issue once the mysql error problem was fixed, thanks for your help. I feel stupid, haha.


All times are GMT +1. The time now is 09:30 PM.

Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.