MySQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesMySQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old May 29th, 2005, 05:29 AM
gamewaves gamewaves is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2005
Posts: 1 gamewaves User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 m 37 sec
Reputation Power: 0
Arrow INSERT INTO mysql dbase using PHP problem

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

Reply With Quote
  #2  
Old May 29th, 2005, 11:12 AM
kzar kzar is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2005
Posts: 6 kzar User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 12 m 30 sec
Reputation Power: 0
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

Reply With Quote
  #3  
Old May 29th, 2005, 04:12 PM
Madpawn Madpawn is offline
My beat is correct.
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Posts: 339 Madpawn User rank is Private First Class (20 - 50 Reputation Level)Madpawn User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 2 Days 22 h 3 m 33 sec
Reputation Power: 4
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:
 $result mysql_query($query) or die(mysql_error()); 


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"


Reply With Quote
  #4  
Old June 20th, 2005, 06:40 AM
Laban Laban is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2005
Posts: 40 Laban User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 8 h 15 m 32 sec
Reputation Power: 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']}'
					)";

Reply With Quote
  #5  
Old June 21st, 2005, 12:03 AM
iahmed iahmed is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2003
Location: USA
Posts: 171 iahmed User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 42 m 58 sec
Reputation Power: 6
echo sql ... and see the result....

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesMySQL Development > INSERT INTO mysql dbase using PHP problem


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway