Current location: Hot Scripts Forums » Other Discussions » Database » db insert


db insert

Reply
  #1 (permalink)  
Old 08-03-11, 11:41 AM
d1canobe d1canobe is offline
Newbie Coder
 
Join Date: Jul 2011
Posts: 10
Thanks: 2
Thanked 0 Times in 0 Posts
db insert

hello. I have a user registration script that tells me the details have been registered succesfully but there's nothing in my db. i'm new to this so can't see the problem. here's the script if anybody can help.

PHP Code:

<?php
include 'mysql-connect.php';
$username mysql_real_escape_string($_POST['username']);
$password mysql_real_escape_string($_POST['password']);
$fullname mysql_real_escape_string($_POST['fullname']);
$email mysql_real_escape_string($_POST['email']);
$ip $_SERVER['REMOTE_ADDR'];

$result mysql_num_rows(mysql_query("SELECT * FROM users WHERE username='$username'"));
if(
$result == 1)
        {
        echo 
'<p>ERROR! The username you have chosen already exists<p>';
        }
else
        {
        
mysql_query("INSERT INTO users (username, password, fullname, email) 
VALUES ('
$username', '$password', '$fullname', '$email')");


        echo 
'<p>Congratulations! You have successfully registered!</p>
                <p>Click <a href="login.php">here</a> to login.</p>'
;
        }
?>
Thanks

Last edited by digioz; 08-03-11 at 08:05 PM.
Reply With Quote
  #2 (permalink)  
Old 08-07-11, 12:01 PM
nafirici nafirici is offline
Newbie Coder
 
Join Date: Mar 2011
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
are you getting an error?
__________________
Nafirici | MN Real Estate
Reply With Quote
  #3 (permalink)  
Old 08-08-11, 04:56 AM
Nico's Avatar
Nico Nico is offline
Community Leader
 
Join Date: Sep 2005
Location: Spain
Posts: 8,075
Thanks: 11
Thanked 88 Times in 83 Posts
Replace:

PHP Code:

mysql_query("INSERT INTO users (username, password, fullname, email) 
VALUES ('
$username', '$password', '$fullname', '$email')"); 
... with:

PHP Code:

mysql_query("INSERT INTO users (username, password, fullname, email) 
VALUES ('
$username', '$password', '$fullname', '$email')") OR die(mysql_error()); 
And post the error you get here.
Reply With Quote
  #4 (permalink)  
Old 08-12-11, 01:15 AM
d1canobe d1canobe is offline
Newbie Coder
 
Join Date: Jul 2011
Posts: 10
Thanks: 2
Thanked 0 Times in 0 Posts
Contacted my host provider. Seems there was an error with the server stopping the db from working. Thanks for your help
Reply With Quote
  #5 (permalink)  
Old 08-12-11, 08:02 AM
LondonTown LondonTown is offline
Disabled
 
Join Date: Aug 2011
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
i had a similar issue, cheers for the help.
Reply With Quote
Reply

Bookmarks

Tags
connection, insert


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with Auto Dealer Script nuzzle PHP 17 04-14-10 08:34 PM
[SOLVED] Friend to Friend Shortest Path sandeep.kumar Database 51 01-15-09 03:12 AM
insert to db timolein PHP 5 11-08-06 04:38 AM
SQL db - custom insert and select query app needed ATS16805 ASP.NET 1 06-24-05 04:38 PM


All times are GMT -5. The time now is 05:20 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.