Jump to content

Adding info to MySQL database


cobusbo

Recommended Posts

Hi Im having some trouble implementing info into a database

 

I got the line

 

 



$mxitid = $_SERVER["HTTP_X_MXIT_USERID_R"];


 

Which I'm importing to my database via

 

 

 



$sql = "INSERT INTO ".$dbTable." (StringyChat_ip,StringyChat_name,StringyChat_message,StringyChat_time,mxit_id) VALUES (\"$ip\",\"$name\",\"$message\",$post_time,$mxitid)";
                  $result = mysql_query($sql);


 

well its working perfectly, but the problem I'm experiencing is that if my value

 



$_SERVER["HTTP_X_MXIT_USERID_R"]


cannot be retrieved I can't insert any info to my database.

 

the

 



$_SERVER["HTTP_X_MXIT_USERID_R"]


is being used via a specific platform called mxit, so if I use any other platform it don't work. Is there maybe a way to change the line

 



$mxitid = $_SERVER["HTTP_X_MXIT_USERID_R"];


to a function if the info couldn't be retrieved to insert another default value like "ADMIN" rather in the place of it?

Link to comment
https://forums.phpfreaks.com/topic/290767-adding-info-to-mysql-database/
Share on other sites

 

A simple checkup before you go for the query should work this out. Just check if the value has been stored into the variable, else put some default value there.

$mxitid = $_SERVER["HTTP_X_MXIT_USERID_R"];

if(!isset($mxitid))
{
	$mxitid = "DEFAULT";
}

Thank you

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.