SpireLink Posted July 24, 2007 Share Posted July 24, 2007 I am working on a club software which will allow me to manage players and get a list of all the registerd players, i can add, get list of all of the players, but when i try to modify any one of them i cant .. i have attached the players edit file .. [attachment deleted by admin] Quote Link to comment Share on other sites More sharing options...
GingerRobot Posted July 24, 2007 Share Posted July 24, 2007 If you were to post the relevant script rather than give us a link to the full code, you'd probably get more responses. However, to get you started, try adding an or die statement to your query: <?php $update=" UPDATE players SET name='$name',recordid='$recordid',dob='$dob',tall='$tall',weight='$weight',picture='$picture' WHERE id=$player_id"; $new_club=mysql_query($update,$db) or die(mysql_error().'<br />On query:'.$update); ?> Quote Link to comment Share on other sites More sharing options...
stlewis Posted July 24, 2007 Share Posted July 24, 2007 I'm afraid you've described your problem a bit ambiguously...do you mean to say that your SQL UPDATE statement does not appear to be working? Is it returning some kind of error? I glanced over your script, and one thing you might consider adding is something to this effect: $update_successful=mysql_query($query); if ($update_successful) { //Do stuff intended when the update goes well... } else { die("Could not update the record<br />".mysql_error()); } That way, if your SQL statement fails for any reason, you can find out the reason why by echoing the mysql_error(); method. Quote Link to comment Share on other sites More sharing options...
SpireLink Posted July 25, 2007 Author Share Posted July 25, 2007 If you were to post the relevant script rather than give us a link to the full code, you'd probably get more responses. However, to get you started, try adding an or die statement to your query: <?php $update=" UPDATE players SET name='$name',recordid='$recordid',dob='$dob',tall='$tall',weight='$weight',picture='$picture' WHERE id=$player_id"; $new_club=mysql_query($update,$db) or die(mysql_error().'<br />On query:'.$update); ?> Thanks for your responce , i have tried it but it didnt work for me, as for the related file ihave attached it ... [attachment deleted by admin] Quote Link to comment Share on other sites More sharing options...
SpireLink Posted July 25, 2007 Author Share Posted July 25, 2007 I'm afraid you've described your problem a bit ambiguously...do you mean to say that your SQL UPDATE statement does not appear to be working? Is it returning some kind of error? I glanced over your script, and one thing you might consider adding is something to this effect: $update_successful=mysql_query($query); if ($update_successful) { //Do stuff intended when the update goes well... } else { die("Could not update the record<br />".mysql_error()); } That way, if your SQL statement fails for any reason, you can find out the reason why by echoing the mysql_error(); method. Thank you very much, i tried the error function and i got this You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 On query: UPDATE players SET name='SpireLink',recordid='7133',dob='11/11/1984',tall='150',weight='45',picture='alsadi.jpg' WHERE id= could you please explain why i cant send the player id to the query? Quote Link to comment Share on other sites More sharing options...
shivani.shm Posted July 25, 2007 Share Posted July 25, 2007 just try this $player_id=$_POST["id"]; with your id in double quotes. Quote Link to comment Share on other sites More sharing options...
plutomed Posted July 25, 2007 Share Posted July 25, 2007 Try this $update="UPDATE players SET name='$name',recordid='$recordid',dob='$dob',tall='$tall',weight='$weight',picture='$picture' WHERE id='$player_id'"; Quote Link to comment Share on other sites More sharing options...
SpireLink Posted July 25, 2007 Author Share Posted July 25, 2007 just try this $player_id=$_POST["id"]; with your id in double quotes. Thanks , i tried it but it didnt work , it gives me an arror the same one that i am getting in replay #4 Quote Link to comment Share on other sites More sharing options...
SpireLink Posted July 25, 2007 Author Share Posted July 25, 2007 Try this $update="UPDATE players SET name='$name',recordid='$recordid',dob='$dob',tall='$tall',weight='$weight',picture='$picture' WHERE id='$player_id'"; I have tried it and i got this error Could not update the record Query was empty Quote Link to comment Share on other sites More sharing options...
plutomed Posted July 25, 2007 Share Posted July 25, 2007 This might work: $update="UPDATE `players` SET name='".$name."',recordid='".$recordid."',dob='".$dob."',tall='".$tall."',weight='".$weight."',picture='".$picture."' WHERE id='".$player_id."'"; Quote Link to comment Share on other sites More sharing options...
SpireLink Posted July 25, 2007 Author Share Posted July 25, 2007 This might work: $update="UPDATE `players` SET name='".$name."',recordid='".$recordid."',dob='".$dob."',tall='".$tall."',weight='".$weight."',picture='".$picture."' WHERE id='".$player_id."'"; i am sorry it didnt work also, it might be a mestake by me .. could you pleae update the attached files so i will upload it, i am sorry to ask you for this and i know that your time is more valuable .. Quote Link to comment Share on other sites More sharing options...
plutomed Posted July 25, 2007 Share Posted July 25, 2007 Could you stick this in over your query and tell me what error comes up $new_club=mysql_query("UPDATE players SET name='$name',recordid='$recordid',dob='$dob',tall='$tall',weight='$weight',picture='$picture' WHERE id=$player_id") or die(mysql_error()); Quote Link to comment Share on other sites More sharing options...
SpireLink Posted July 25, 2007 Author Share Posted July 25, 2007 i am getting this error now [QOUTE] You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 3 [/QOUTE] Quote Link to comment Share on other sites More sharing options...
plutomed Posted July 25, 2007 Share Posted July 25, 2007 This might make a difference: $new_club=mysql_query("UPDATE `players` SET `name`='$name',`recordid`='$recordid',`dob`='$dob',`tall`='$tall',`weight`='$weight',`picture`='$picture' WHERE `id`='$player_id'") or die(mysql_error()); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.