Jump to content

Adding info to MySQL database


Go to solution Solved by lawless,

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

  • Solution

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";
}

 

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.