PDA

View Full Version : Inserting Data, my new problem...



Freddythunder
June 30th, 2003, 08:31 PM
Hello again!! Didn't take me too long, did it?

I'm having a problem with inserting info into a database. I know it has to be something easy like I'm missing a ' or something. I've been looking at tutorials and trying all different kinds of things but keep getting the 'or die' message after the query. Anybody got an idea?
BTW - I won't get as intense as last post...eh?

Thank you!!

http://www.freddythunder.com/test/submit.txt

Digitalosophy
July 1st, 2003, 01:04 AM
hey man. jubba helped me with this an it works perfect. it also sends me an email when a new user signs up, i ddint take that out


<?
$name = $_POST['name'];
$Email = "sosick@digitalosophy.com";
$Subject = "Mailing List Sign Up";
$Header = "From: sosick@digitalosophy.com";
$Message = "$name has signed up.";

mail($Email, $Subject, $Message, $Header);

@ $db = mysql_pconnect("localhost", "un", "pw");

if (!$db){
echo "Error: Could not connect to database. Please try agian later.";
exit;
}
mysql_select_db("db");
$query = "insert into mailinglist(email) values('$name')";
$result = mysql_query($query);
if ($result) {
echo mysql_affected_rows()." name inserted into database.";
}




?>


Flash var is name

Digitalosophy
July 1st, 2003, 01:05 AM
o i just seen u had a txt attached. lol, not sure what ur doing wrng in your code, maybe you can compare the two

Digitalosophy
July 1st, 2003, 05:21 PM
any luck freddy?

Freddythunder
July 1st, 2003, 06:08 PM
No. That script sends me (numerous) emails so the php script is working, but nothing ever gets inserted into my db. I do have four fields in the database, but I don't have to name them all in the query, do I?

Digitalosophy
July 1st, 2003, 06:38 PM
$query = "insert into books(isbn, author, title, price) values('$isbn', '$author', '$title', '$price')";


yes you do ... i think anyway. this is how i did another project and it works fine

Freddythunder
July 1st, 2003, 07:27 PM
You'll have to pardon me, my PHP is so new, it's still in the wrapper.

If I had in my create table script that I used that one of those fields is 'userID' and it's on auto-increment, do I still have to input something? My guestbook one (that works fine) adds in four zeros in that space. I tried that to no avail!! Drat. Any ideas about that? I'm gonna try a few hundred more times tonight..

Digitalosophy
July 1st, 2003, 07:37 PM
$query = "insert into auth(userName, userPassword) VALUES('$newUser', '$newPass')";


do me a favor, before you go nuts, try that it should def work as long as your capturing those variable names and correctly

oh and yea me too, im learining php day by day. i had a lot of trouble at first but now it's getting a little bit easier

Freddythunder
July 1st, 2003, 08:13 PM
This is the message I got:

bobcatInsertFailed!

let me translate:
$newUser/$newPass/or die message from query

that means the two passwords entered mached and all the vars are posting correctly. It must be the empty cells that don't get filled - maybe...

Digitalosophy
July 1st, 2003, 08:24 PM
hmm, so no data got entered?

Freddythunder
July 1st, 2003, 08:46 PM
ARE YOU READY FOR A LAUGH!! IT'S A DOOZIE!!

I'm an idiot. So, have you heard about that silly little 'case sensitivity thing' that UNIX has goin'?

Yeah, well I guess using userID and userPassword was a bad idea. I thought of that and tried to enter my password into mysqladmin with one capitol letter. He didn't recognize me.

So we all learned a very valuble lesson. don't ever use capitol letters again (unless is AS :P)....

Once again - thank you Digital - VICTORY IS OURS!!

Digitalosophy
July 2nd, 2003, 01:51 AM
lmao, no doubt man glad to see ur up and running