943,987 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Marked Solved
  • Views: 592
  • PHP RSS
Oct 6th, 2009
0

Insert Statement not working?

Expand Post »
I throw the exact same sql statement in phpmyadmin and it works but it does not work with mysql_query.

Ideas?

PHP Syntax (Toggle Plain Text)
  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);
Similar Threads
Reputation Points: 31
Solved Threads: 10
Practically a Master Poster
OmniX is offline Offline
652 posts
since Dec 2007
Oct 6th, 2009
0
Re: Insert Statement not working?
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 -
PHP Syntax (Toggle Plain Text)
  1. echo "=>".mysql_error();
and post the output of echo here.
Reputation Points: 29
Solved Threads: 76
Practically a Master Poster
network18 is offline Offline
616 posts
since Sep 2009
Oct 6th, 2009
0
Re: Insert Statement not working?
Click to Expand / Collapse  Quote originally posted by OmniX ...
I throw the exact same sql statement in phpmyadmin and it works but it does not work with mysql_query.

Ideas?

PHP Syntax (Toggle Plain Text)
  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.
Reputation Points: 10
Solved Threads: 4
Newbie Poster
basantxbs is offline Offline
12 posts
since Apr 2009
Oct 6th, 2009
0
Re: Insert Statement not working?
hi
mabye there is some filed dosent accept null filed

check it , and print mysql_error($query);
Reputation Points: 10
Solved Threads: 2
Newbie Poster
mohdsh85 is offline Offline
3 posts
since Aug 2009
Oct 6th, 2009
0
Re: Insert Statement not working?
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?
Reputation Points: 31
Solved Threads: 10
Practically a Master Poster
OmniX is offline Offline
652 posts
since Dec 2007

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: Interactive Timetable - Assign timeslots
Next Thread in PHP Forum Timeline: Email error - PHP





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC