auto incresement ID

Discussion in 'PHP' started by yuyue_hirakiseira, May 11, 2010.

  1. #1
    hi there, i having problem in auto increment in my sql database.
    i've tried it but i didn't get error or any data into my database.
    here's the code that i've tried
    i actually wanted my ID to be M001 but the database couldn't allow me to have the varchar for auto increment
    please help!
    thanks in advance

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">

    <head>
    <meta content="en-us" http-equiv="Content-Language" />
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
    <title>Name</title>
    </head>

    <body>

    <?php
    if (isset($_POST['submit'])){
    $con = mysql_connect("127.0.0.1","root","2614352") or trigger_error("Connection Failed: ".mysql_error($con), E_USER_ERROR);

    mysql_select_db("cbfsms", $con);

    $_POST = array_map('mysql_real_escape_string', $_POST);

    $sql="INSERT INTO member (null,MemName, MemAdd, MemContact, MemEmail)
    VALUES
    ('{$_POST[MemID]}','{$_POST['MemName']}','{$_POST['MemAdd']}','{$_POST['MemContact']}','{$_POST['MemEmail']}')";

    if (mysql_query($sql,$con)){
    echo "1 record added";
    } else {
    trigger_error("Query Failed: ".mysql_error($con), E_USER_ERROR);
    }

    mysql_close($con);
    }
    ?>

    <form method="post">
    Name: <input name="MemName" type="text" /><br />
    <br />
    Address: <input name="MemAdd" type="text" /><br />
    <br />
    Email: <input name="MemEmail" type="text" /><br />
    <br />
    Contact: <input name="MemContact" type="text" /><br />
    <br />
    &nbsp;&nbsp;&nbsp; <input name="clear" type="button" value="clear" />&nbsp;&nbsp;&nbsp;
    <input name="submit" type="submit" value="submit" />&nbsp;&nbsp;&nbsp;
    <input name="cancel" type="button" value="cancel" /></form>

    </body>

    </html>
     
    yuyue_hirakiseira, May 11, 2010 IP
  2. lorkan

    lorkan Peon

    Messages:
    20
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Hi!

    I answered you other post - check it out!
     
    lorkan, May 11, 2010 IP