To register for an Internet.com membership to receive newsletters and white papers, use the Register button ABOVE.
To participate in the message forums BELOW, click here
For $common, $rares, and $epics, if the form is "" (blank), I want the insert value to be NULL. It has to be NULL or else it will return a row value.
I tried something along the lines of:
Code:
if ($common == "") {
$common = NULL;
}
if ($rares == "") {
$rares = NULL;
}
if $epics == "") {
$epics = NULL;
}
But all that does is insert a 'NULL' value rather than a NULL value. So, I'm not sure how to properly phrase the Insert to include the variable changes. I don't want a text NULL, I want a SQL NULL to be returned when the field is blank.
You are getting the string null because you have quotes around '$common', '$rares', and '$epics'. Change your if then clauses to include quotes only if you are inserting a non-null text value. A quick codefetch search for sql insert null shows that NULL (without quotes) is a valid SQL insert value, at least for mySQL.
The simplest way to guarantee NULL is to specify NULL as the default value for the column affected. Then you can just omit the column from your insert and it will default to the NULL you want.
Also, the best way to build the column and value lists is as seperate strings first
You are getting the string null because you have quotes around '$common', '$rares', and '$epics'. Change your if then clauses to include quotes only if you are inserting a non-null text value. A quick codefetch search for sql insert null shows that NULL (without quotes) is a valid SQL insert value, at least for mySQL.
Yes, I understand that part and stated in my post that I understood that. What I need help with is phrasing the If > Then clause so that it properly formats the Insert SQL query.
If I remove the ('quotes') within the SQL query and place a variable, it does not work.
So, again, I need help with "creating" the if then clause to properly format the sql query.
Thanks in advance to any senior members that assist.
The simplest way to guarantee NULL is to specify NULL as the default value for the column affected. Then you can just omit the column from your insert and it will default to the NULL you want.
Also, the best way to build the column and value lists is as seperate strings first