Activity Stream
48,167 MEMBERS
61070 ONLINE
besthostingforums On YouTube Subscribe to our Newsletter besthostingforums On Twitter besthostingforums On Facebook besthostingforums On facebook groups

Results 1 to 10 of 10
  1.     
    #1
    Banned
    Website's:
    CloudNXT.net

    Default MySQL insert using PHP Help

    PHP Code: 
    <?php
    $con 
    mysql_connect("localhost","MYSQL USERNAME","MYSQL PASS");
    if (!
    $con)
      {
      die(
    'Could not connect: ' mysql_error());
      }

    mysql_select_db("seedvps_whm"$con);

    $sql="INSERT INTO tblcustomaddon location, status, username, password, ip);
    VALUES
    ('
    $_POST[location]','$_POST[status]','$_POST[username]','$_POST[password]','$_POST[ip]')";

    if (!
    mysql_query($sql,$con))
      {
      die(
    'Error: ' mysql_error());
      }
    echo 
    "1 record added";

    mysql_close($con)
    ?>
    Post
    Code: 
    <html>
    
    <body>
    
    
    
    <form action="insert.php" method="post">
    
    Location: <input type="text" name="location" />
    
    Status: <input type="text" name="status" />
    
    Username: <input type="text" name="username" />
    
    Password: <input type="text" name="password" />
    
    IP: <input type="text" name="ip" />
    
    <input type="submit" />
    
    </form>
    
    
    
    </body>
    
    </html>
    Error
    Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'location, status, username, password, ip) VALUES ('fr','jaja','BigBoSs','kaka'' at line 1
    EnCiPh3r Reviewed by EnCiPh3r on . MySQL insert using PHP Help <?php $con = mysql_connect("localhost","MYSQL USERNAME","MYSQL PASS"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("seedvps_whm", $con); $sql="INSERT INTO tblcustomaddon location, status, username, password, ip); Rating: 5

  2.   Sponsored Links

  3.     
    #2
    Just Another Coder
    try this out

    PHP Code: 
    <?php
    $con 
    mysql_connect("localhost","MYSQL USERNAME","MYSQL PASS");
    if (!
    $con)
      {
      die(
    'Could not connect: ' mysql_error());
      }

    mysql_select_db("seedvps_whm"$con);

    $sql="INSERT INTO tblcustomaddon (location, status, username, password, ip) VALUES ('$_POST[location]','$_POST[status]','$_POST[username]','$_POST[password]','$_POST[ip]')";

    if (!
    mysql_query($sql,$con))
      {
      die(
    'Error: ' mysql_error());
      }
    echo 
    "1 record added";

    mysql_close($con)
    ?>

  4.     
    #3
    Banned
    Website's:
    CloudNXT.net
    Worked like a charm!!!!

  5.     
    #4
    Just Another Coder
    Quote Originally Posted by EnCiPh3r View Post
    Worked like a charm!!!!
    You just missed a '(' before location and you shouldn't add ';' before VALUES where the query is not ending yet.

  6.     
    #5
    Banned
    Website's:
    CloudNXT.net
    Quote Originally Posted by fdls View Post
    You just missed a '(' before location and you shouldn't add ';' before VALUES where the query is not ending yet.
    Thanks man btw is there any way i can do the same script without adding my mysql user and pass information because those are already present in configuration.php (WHMCS)

  7.     
    #6
    Member
    Website's:
    sborg.us
    By including the configuration.php file and using the same variables?

    V3g3ta | Halcyon | Abhi

  8.     
    #7
    Just Another Coder
    yea simple <?php include('config.php'); ?>

    EDIT: Oops he already replied on that one.

  9.     
    #8
    Member
    Website's:
    sborg.us
    You can use require too -> To make sure that the file is included. Else the script throws errors (in case you have them enabled).

    V3g3ta | Halcyon | Abhi

  10.     
    #9
    Member
    Website's:
    EvilHackerz.Org
    My Friend You Can Also use BigDump For DB Restoration

  11.     
    #10
    Member
    Website's:
    imdber.org justpaste.me
    You should be using pdo by now.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Where can I insert this code?
    By Divvy in forum Wordpress
    Replies: 7
    Last Post: 21st Oct 2011, 10:29 AM
  2. insert PSD file
    By iobit in forum vBulletin
    Replies: 10
    Last Post: 9th Aug 2011, 08:38 AM
  3. insert 100 urls to database in one go ?
    By jack3r in forum Web Application/Script Support
    Replies: 2
    Last Post: 8th Jul 2011, 10:09 PM
  4. Insert Image Code
    By warezboy in forum vBulletin
    Replies: 12
    Last Post: 9th Jun 2010, 06:16 PM
  5. Insert Image CODE
    By tom247 in forum Web Application/Script Support
    Replies: 3
    Last Post: 9th Jun 2010, 05:04 AM

Tags for this Thread

BE SOCIAL