Insert Statement not working?

Thread Solved

Join Date: Dec 2007
Posts: 609
Reputation: OmniX is an unknown quantity at this point 
Solved Threads: 8
OmniX's Avatar
OmniX OmniX is offline Offline
Practically a Master Poster

Insert Statement not working?

 
0
  #1
Oct 6th, 2009
I throw the exact same sql statement in phpmyadmin and it works but it does not work with mysql_query.

Ideas?

  1. $a = "INSERT INTO players (player_id, first_name, last_name, date_of_birth, email, mobile_number, emergency_number, mother_name, father_name, player_number, team_captain, ip_address) VALUES ('', '', '', '', '', '', '', '', '', '', '', '127.0.0.1')"
  2. $q = mysql_query($a);
"You never stop learning." - OmniX
Reply With Quote Quick reply to this message  
Join Date: Sep 2009
Posts: 539
Reputation: network18 is an unknown quantity at this point 
Solved Threads: 63
network18 network18 is offline Offline
Posting Pro
 
0
  #2
Oct 6th, 2009
please check (or post here) with the database's table structure too,
the player_id should have been as 'not null'.
put the below code your line 2 -
  1. echo "=>".mysql_error();
and post the output of echo here.
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 5
Reputation: basantxbs is an unknown quantity at this point 
Solved Threads: 1
basantxbs basantxbs is offline Offline
Newbie Poster
 
0
  #3
Oct 6th, 2009
Originally Posted by OmniX View Post
I throw the exact same sql statement in phpmyadmin and it works but it does not work with mysql_query.

Ideas?

  1. $a = "INSERT INTO players (player_id, first_name, last_name, date_of_birth, email, mobile_number, emergency_number, mother_name, father_name, player_number, team_captain, ip_address) VALUES ('', '', '', '', '', '', '', '', '', '', '', '127.0.0.1')"
  2. $q = mysql_query($a);
May be your player_id is the primary key that's why it is not inserting. primary key should not be null. Check your table structure.
Reply With Quote Quick reply to this message  
Join Date: Aug 2009
Posts: 3
Reputation: mohdsh85 is an unknown quantity at this point 
Solved Threads: 2
mohdsh85 mohdsh85 is offline Offline
Newbie Poster
 
0
  #4
Oct 6th, 2009
hi
mabye there is some filed dosent accept null filed

check it , and print mysql_error($query);
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 609
Reputation: OmniX is an unknown quantity at this point 
Solved Threads: 8
OmniX's Avatar
OmniX OmniX is offline Offline
Practically a Master Poster
 
0
  #5
Oct 6th, 2009
Dont know what I did but I solved it... lol
I think I just reconstructed the sql query a different way to give me the same output and it worked.

PS: isnt "" not a NULL but a defined value?
PPS: it wouldnt matter in this case as the PK has AI attached?
"You never stop learning." - OmniX
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC