Jump to content

[SOLVED] My update function doesn't work


cyberthug

Recommended Posts

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

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)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.