Hi,
I am taking data from a web form and creating an "insert string", or variable that will be used to insert the data into a mySQL database table. See my sample code below.
My code (not exact here) flows something like this
//check or validate data from form
if($evt_nm == ""){
//set $error_msg, etc
}
//more error checking and some manipulation
if($error_msg == ""){ //no known errors
//create insert string or variable to insert row
$insert_string = "'$evt_type', '$evt_nm', '$evt_desc', '$evt_cost',
'$evt_create_dt' , '$evt_create_unm' ";
//pass the insert string to a function to insert the data
}else{ //do error routine; }
Here's my problem some of these variables I place in my insert string need to be set to null under certain conditions
For Example
if($evt_type == "MEETING"){
$evt_nm = NULL;
}
then I place that variable in the insert string variable for the insert and it doesn't work
HELP - How should design or write this code, so that I can conditionally set a variable to NULL and place it in an "insert string" or variable, as shown above that can be used to insert a row into a mySQL database table correctly?
I don't want to be rude here, but the requirement is that I must be able to conditionally set some of the variables from the form, used in the "insert string" variable to NULL.
The value of this design is that I don't need a million inserts. I have a function that takes this string some other information and does the insert with error checking etc.
Thanks SO MUCH!!!!