|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Hi Everyone,
I have a problem and i wold be very gratefull if you could help me out. I have a piece of code which is not working but i dont know why? Here it is: PHP code $query = "INSERT INTO users (uname, upass, fname, sname, country, city, email, website, date, cat1, cat1name,cat2, cat2name,cat3, cat3name,cat4, cat4name, cat5, cat5name,cat6, cat6name,cat7, cat7name,cat8, cat8name) VALUES('$uname','$upass','$fname','$sname','$count ry','$city','$email','$website','$date','$cat1','$ cat1name','$cat2','$cat2name','$cat3','$cat3name', '$cat4','$cat4name','$cat5','$cat5name','$cat6','$ cat6name','$cat7','$cat7name','$cat8','$cat8name') "; echo $query; $result = mysql_query($query); An echo of the quesry is... INSERT INTO users (uname, upass, fname, sname, country, city, email, website, date, cat1, cat1name,cat2, cat2name,cat3, cat3name,cat4, cat4name, cat5, cat5name,cat6, cat6name,cat7, cat7name,cat8, cat8name) VALUES('1','1','1','1','United States','1','1','http://','29 May, 2005','sssdddd|http://www.lll.com ','New Category Name','ddd|http://www.kkl.com mossad|http://www.mossad,.com idf|http://www.idf.il ','New Category Name','hotmail|http://www.hotmail.com ','New Category Name','','NULL','','NULL','','NULL','','NULL','',' NULL') Thanks for any of your comments or suggestions. Simon |
|
#2
|
|||
|
|||
|
Hi,
can't tell for sure but check your query when you insert the values of cat1name. It seems that there is a space after $. Again i can't be sure as i copy paste the code to test it. Other than that, perhaps the // at the urls may cause some problems. Try using str_replace to fix this |
|
#3
|
|||
|
|||
|
Please be more specific about 'not working'. Is it just not inserting, or is it inserting incorrectly?
To help debug, do this for you query call: PHP Code:
If the db server is kicking back an error, this will kill the script and give you an error message.
__________________
"A pawn is the most important piece on the chessboard -- to a pawn" |
|
#4
|
|||
|
|||
|
Looks like you are inserting values gathered from a form, correct?
If so...you need to specify what belongs to what...perhaps you done that but your posted code doesn't show it. Just saying VALUE($whatever1) won't work...you need to add the $_POST or $_GET cmd (depending what your form says). Code:
$sql = "INSERT INTO
tbl_whatever (whatever1, whatever2, whatever3)
VALUES
('{$_POST['whatever1']}',
'{$_POST['whatever2']}',
'{$_POST['whatever3']}'
)";
|
|
#5
|
|||
|
|||
|
echo sql ... and see the result....
|
![]() |
| Viewing: Dev Articles Community Forums > Databases > MySQL Development > INSERT INTO mysql dbase using PHP problem |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|