Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Jul 2011
    Posts
    141
    Thanks
    8
    Thanked 0 Times in 0 Posts

    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>

  • #2
    Regular Coder LearningCoder's Avatar
    Join Date
    Jan 2011
    Location
    The Pleiades
    Posts
    924
    Thanks
    76
    Thanked 29 Times in 29 Posts
    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-06-2013 at 12:42 AM.

  • #3
    Regular Coder
    Join Date
    Jul 2011
    Posts
    141
    Thanks
    8
    Thanked 0 Times in 0 Posts
    Thank you, i was able to fix the issue once the mysql error problem was fixed, thanks for your help. I feel stupid, haha.


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •