Can't save a variable in the database. Why?

Hi,

I am trying to register a user.

Once the user is registered, a call to an external API is made.

It return a clientID.

I need to take this clientID, and save it in the database. …but it doesn’t save the clientID…

Here is my code :

[php]$createAccount = $MySession->register($user, $pass,
array(
“email” => $email,
“name” => $name,
“created” => date(“Y-m-d H:i:s”)
)
);
if($createAccount === “ExistingUser”){
echo “Client already exist!”;
}elseif($createAccount === true){
$response = (Client::add_client(array(‘firstname’ => $user, ‘name’ => $name, ‘email’ => $email)));
$response = array();
foreach($response as $Element){
$IDClient=$Element->clientid;

				$hote="localhost";
				$usern="XXXXXXX";
				$passw="XXXXXXX";
				$basedata="XXXXXXX";

				mysql_connect($hote,$usern,$passw);
				@mysql_select_db($basedata) or die( "Unable to select database");
				$query= "UPDATE `users`   
				 SET `clientid` = :'{$IDClient}'
				 WHERE `email` = :{$email}";
				mysql_query($query);
				mysql_close();}

	}
	return true;
		echo "HOURRAH!  Your account was created :)";
    		
   	}[/php]

It can create the account, but i doesn’t save the ClientID in the database.

Why exactly?

Thank you in advance :slight_smile:

  1. Are you using some kind of framework? I see a static method and an instance method.
  2. using the @ in front suppresses errors, errors are you friend. That is if you even have error checking turned on. An take no offense but I find it a little funny where you have the @ symbol at. ;D

and

  1. mysql is obsolete, you really should be using PDO or mysqli. However, I probably here some reason that you can’t, so someone else will need to help with number 3.
Sponsor our Newsletter | Privacy Policy | Terms of Service