It is currently Fri Mar 29, 2024 7:19 am


All times are UTC


Forum rules


Please click here to view the forum rules



Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: php is bad to me
PostPosted: Sun Apr 23, 2006 2:28 pm 
Noobie
Noobie

Joined: Fri Apr 07, 2006 1:17 am
Posts: 8
Hi,
I am new to php, and I am trying to write a simple script that adds records to a database. I have been trying for 3 days now, but I can't seem to get it to actually add anything to the db.

Is there something extra that has to be added to access the db or am i doing something wrong?

<here's the script>
Code:
<?
$sqname="*******_dotm";
$sqpass="*******";

mysql_connect("65.98.98.58",$sqname,$sqpass);
@mysql_select_db("******_dotm") or die("Unable to select database");


$fname = $_POST['FN'];
$lname = $_POST['LN'];
$uname = $_POST['UN'];
$upass = $_POST['PASS'];
$cpass = $_POST['PASS2'];
$email = $_POST['EM'];

$url = $_POST['URL'];
$aim = $_POST['AIM'];
$msn = $_POST['MSN'];
$yah = $_POST['YAH'];
$not = $_POST['NOT'];

$post = "INSERT INTO Users VALUES ($fname,$lname,$uname,$upass,$email,$url,$aim,$msn,$yah,$not)";
mysql_query($post);


mysql_close();
?>


Last edited by The_Potato on Sun Apr 23, 2006 5:07 pm, edited 4 times in total.

Top
 Profile  
 
 Post subject:
PostPosted: Sun Apr 23, 2006 3:36 pm 
Posts like crazy!
Posts like crazy!

Joined: Mon Sep 26, 2005 5:03 pm
Posts: 204
Location: The Netherlands
The database name should be the same as the user name.. and should have a fomat like this: loginname_dbname

So if you login with potato it should be "potato_users"

At least for free accounts.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Apr 23, 2006 5:04 pm 
Noobie
Noobie

Joined: Fri Apr 07, 2006 1:17 am
Posts: 8
Sorry, I put the wrong script up :oops: , (the files have almost the same name)
I replaced the first posts script with the correct one...

oh yeah and the name "the_Potato" is being used because my actual forum account is not working...

Edit>> the script I put up before doesn't work either, but that was an example from someone else on what it should look like...


Top
 Profile  
 
 Post subject:
PostPosted: Sun Apr 23, 2006 5:22 pm 
Posts like crazy!
Posts like crazy!

Joined: Mon Sep 26, 2005 5:03 pm
Posts: 204
Location: The Netherlands
Well that makes my post kinda useless :P

Anyway I think your problem is that you try to insert strings but you don't quote them.
so try this
Code:
$post = "INSERT INTO Users VALUES ('$fname','$lname','$uname','$upass','$email','$url','$aim','$msn','$yah','$not')";


I'm not entirely sure if I should quote $not as im not sure what it is suppose to be. I did do it, so try without them if it doesn't work.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Apr 23, 2006 5:26 pm 
Noobie
Noobie

Joined: Fri Apr 07, 2006 1:17 am
Posts: 8
sorry i ruined your post,

"not" stands for "notes", it is a text box allowing 255 characters


Top
 Profile  
 
 Post subject:
PostPosted: Sun Apr 23, 2006 5:30 pm 
Posts like crazy!
Posts like crazy!

Joined: Mon Sep 26, 2005 5:03 pm
Posts: 204
Location: The Netherlands
Then I think it should work now.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Apr 23, 2006 5:30 pm 
Noobie
Noobie

Joined: Fri Apr 07, 2006 1:17 am
Posts: 8
IT WORKED!!! YAY!!! :D :D :D

Thank you, You made me feel stupid for spending 3 days on it and you fixed it all in one post! :lol:

Thank you


Top
 Profile  
 
 Post subject:
PostPosted: Sun Apr 23, 2006 5:35 pm 
Posts like crazy!
Posts like crazy!

Joined: Mon Sep 26, 2005 5:03 pm
Posts: 204
Location: The Netherlands
Glad it worked..
It's one of those small things you just have to find out. It is quite annoying that mysql doesnt throw a warning/error. Instead it simply doesn't processes it. :(


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ]  Moderators: fhmagic, KJ, Moderators, Support Team

All times are UTC


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
100WebSpace © 2011