Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PHP mysql insert issue

Status
Not open for further replies.

dagoat10

Programmer
Jun 3, 2010
74
US
i am having a problem with my insert and delete using php

i delete a player and i am left with a blank ID 0 entry spot in my table, i tried to get rid of it with another delete but it is not working inless i manually go into the table and remove the ID 0 myself

Code:
 $query2="INSERT INTO $_SESSION[T] (ID, Player, Pos, Team) Values('$ID', '$_POST[Plyr]', '$Pos', '$Team')";
        echo "Insert worked";
        mysql_query($query2, $conn);
        echo mysql_error();

Code:
$query4="DELETE FROM $_SESSION[T] where Player='$CutP'";
echo mysql_affected_rows();
mysql_query($query4, $conn);
echo mysql_error();

$query5="DELETE FROM $_SESSION[T] where Player=''";
echo mysql_affected_rows();
mysql_query($query5, $conn);
echo mysql_error();

what have i done wrong, could it be that my create table ID field is set to NOT NULL?
 
I don't see anything wrong apart from your call to mysql_affected_rows, which wont produce a meaningful answer, since you are calling it before actually executing the query.

How do you know it leaves a row with an Id of 0. Are you displaying the records afterward? There may be some problem with your display code.

Are you using some kind of GUI to look at the table?

If so which one?

Also what is the table definition?



----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Behind the Web, Tips and Tricks for Web Development.
 
well it's ok i fixed it now, i just had to add a conditional delete.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top