cyberthug Posted June 10, 2009 Share Posted June 10, 2009 I'm a Flex developer learning amfphp. Attempting to setup basic CRUD functions. Here's my code. Everything works except the update. I don't get any errors but the db row isn't updated. Any assistance would be greatly appreciated. <?php class services { public function services() { $mysql= mysql_connect("localhost", "root" , "root"); mysql_select_db("sports_friend_finder"); } //get list of all registered friends public function getFriends() { $result = mysql_query("SELECT * FROM friends"); $friends = array(); while($row = mysql_fetch_assoc($result)) { $friends[] = $row; } return $friends; } // add friends to list public function addFriend ( $athletesfirstname, $athleteslastname, $athletessport, $athletesusername, $athletespassword, $athleteszipcode ) { $sql = "INSERT INTO friends ( athleteskey, athletesfirstname, athleteslastname, athletessport, athletesusername, athletespassword, athleteszipcode) VALUES (NULL, '$athletesfirstname', '$athleteslastname' , '$athletessport' , '$athletesusername' , '$athletespassword' , '$athleteszipcode')"; return mysql_query ($sql); } // delete friends from database' public function deleteFriend ($athleteskey) { $sql = "DELETE FROM `friends` WHERE `athleteskey` = $athleteskey"; return mysql_query ($sql); } /*get last friend that joined public function getLastFriend() { $sql = "SELECT * FROM 'friends' ORDER BY athleteskey' DESC LIMIT 1;"; return mysql_query (sprintf($sql)); } */ //update friend public function updateFriend($athleteskey, $athletesfirstname, $athleteslastname, $athletessport, $athletesusername, $athletespassword, $athleteszipcode) { $sql = "UPDATE 'friends' SET athletesfirstname='$athletesfirstname',athleteslastname='$athleteslastname', athletessport='$athletessport', athletesusername='$athletesusername', athletespassword='$athletesuserpassword', athleteszipcode='$athleteszipcode' WHERE 'athleteskey' =$athleteskey"; return mysql_query ($sql); } } ?> Link to comment https://forums.phpfreaks.com/topic/161701-solved-my-update-function-doesnt-work/ Share on other sites More sharing options...
tivrfoa Posted June 10, 2009 Share Posted June 10, 2009 hey! change this return mysql_query ($sql); to mysql_query($sql) or die(mysql_error()); just to see what is going on Link to comment https://forums.phpfreaks.com/topic/161701-solved-my-update-function-doesnt-work/#findComment-853194 Share on other sites More sharing options...
cyberthug Posted June 10, 2009 Author Share Posted June 10, 2009 Here's the error I received. (mx.rpc::Fault)#0 errorID = 0 faultCode = "INVALID_AMF_MESSAGE" faultDetail = "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 ''friends' SET athletesfirstname='r',athleteslastname='u ', athletessport='crazy'' at line 1" faultString = "Invalid AMF message" message = "faultCode:INVALID_AMF_MESSAGE faultString:'Invalid AMF message' faultDetail:'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 ''friends' SET athletesfirstname='r',athleteslastname='u ', athletessport='crazy'' at line 1'" name = "Error" rootCause = (null) Link to comment https://forums.phpfreaks.com/topic/161701-solved-my-update-function-doesnt-work/#findComment-853217 Share on other sites More sharing options...
cyberthug Posted June 10, 2009 Author Share Posted June 10, 2009 Thanks, I figured it out. I removed the single quotes from the db table name and it worked. Link to comment https://forums.phpfreaks.com/topic/161701-solved-my-update-function-doesnt-work/#findComment-853221 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.