another mySQL question 
Author Message
 another mySQL question

this one is very closely related to my last one as far as using an array.

$stuff = array($login, $password, $email, $zip, $gender, $dob, $first,
$last, $adress, $city, $state, $country, $aim, $date, $profile);

for($i=0;$i<15;$i++) {

print $stuff[$i] . "<br>";

Quote:
}

$db = mysql_connect("localhost", "", "");

mysql_select_db("post");

mysql_query("INSERT INTO users VALUES
($stuff[0],$stuff[1],$stuff[2],$stuff[3],$stuff[4],$stuff[5],$stuff[6],$stuf
f[7],$stuff[8],$stuff[9],$stuff[10],$stuff[11],$stuff[12],$stuff[13],$stuf[1
4]);");

mysql_close($db);

this should work but i get this error ever time [note that the query is on
line 32]

Parse error: parse error, unexpected T_STRING in C:\Documents and
Settings\me\Desktop\new pa\board\createUser.php on line 32

thanks again a bunch, your last answers were a very big help.



Sat, 21 May 2005 12:18:36 GMT  
 another mySQL question

Quote:

> $db = mysql_connect("localhost", "", "");

> mysql_select_db("post");

> mysql_query("INSERT INTO users VALUES
> ($stuff[0],$stuff[1],$stuff[2],$stuff[3],$stuff[4],$stuff[5],$stuff[6],$stuf
> f[7],$stuff[8],$stuff[9],$stuff[10],$stuff[11],$stuff[12],$stuff[13],$stuf[1
> 4]);");

> mysql_close($db);

Two things that I noticed:

1. Take a look at
http://www.php.net/manual/en/language.types.string.php#language.types...
you may need to enclose your array values in {} inside the string.

2. I don't know what fields you have in the users table, but for varchar
you need to enclose the value in single quotes.

So, I'd try "INSERT INTO ... '{$stuff[0]}' ... " for varchar fields, and
same without quotes for numbers.



Sat, 21 May 2005 14:09:02 GMT  
 another mySQL question
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

($stuff[0],$stuff[1],$stuff[2],$stuff[3],$stuff[4],$stuff[5],$stuff[6],$stuf
f[7],$stuff[8],$stuff[9],$stuff[10],$stuff[11],$stuff[12],$stuff[13],$stuf[1

Quote:
> 4]);");

I spy a missing "f".

(hint: number 14)

Why don't you try this:

mysql_query("INSERT INTO users VALUES"."('".join("','",$stuff)."')");

Best,

- --
Waitman Gobble         EMK Design     Buena Park, California

Public Key                          http://pgp.emkdesign.com
Find an example                    http://freakinexample.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)

iD8DBQE97XhLlkBqm2sl6RIRAmffAJ9msISCTF7lFSjDPNEY4onvwFgCzwCfdmgN
D9VwtsJ4M5cakbcFaJgaT7g=
=zOp0
-----END PGP SIGNATURE-----



Sun, 22 May 2005 11:36:11 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. mySQL question

2. MySQL question: KEY keyname (fieldname, fieldname,...)

3. PHP/mysql question

4. MySQL questions

5. mySQL question

6. OT: Mysql questions

7. MySQL locally vs. MySQL on server

8. question about awk and mysql

9. MySQL/PostgreSQL Question

10. Newbie Question: Object Rexx with MySQL

11. mysql+php account question

12. newbie question: MySQL installation

 

 
Powered by phpBB® Forum Software