Results 1 to 6 of 6

Thread: [RESOLVED] MySQL Insert Problem

Threaded View

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2007
    Location
    Karachi
    Posts
    551

    Resolved [RESOLVED] MySQL Insert Problem

    hello to everYone!!

    i m using following code for inserting the the data in my sql there is no syntax error no exception but the data is not inserting in the database

    i also tried by $_POST instead of $_REQUEST but no result !

    PHP Code:
    <?
    ini_set("display_errors", 0);
    if (isset($_REQUEST['submit'])) {
    $name =$_REQUEST["username"];

    echo $name;
    $dbh=mysql_connect ('localhost','root','mypass');
    mysql_select_db ("newdatabase");

    mysql_query("insert into  newtable (name) values($name)") 
    or die(mysql_error());  
    echo "Data Inserted!";

    }

    if (!isset($_POST['submit'])) { // if page is not submitted to itself echo the form
    ?>
    <html>
    <body>
    <form method="post" action="<?php echo $PHP_SELF;?>">
    <table>
    <tr>
    <td>Please enter your name:</td>
    <td> <input type="text" name="username" /></td>
    </tr>
    <td>Please enter your name1:</td>
    <td> <input type="text" name="username1" /></td>
    </tr>
    <tr><td><input type="submit" value="submit" /></td></tr>
    </table>
    </form>

    <?
    }
     else {
      echo "Hello, " .$_REQUEST['username'];  

    }
    ?>
    Hope any one would reply
    Last edited by penagate; Jul 18th, 2007 at 10:07 AM. Reason: added code tags

Posting Permissions

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



Click Here to Expand Forum to Full Width