Apr 1st, 2014, 10:25 AM
Marco,
Thanks for the wait. We need to create a similar set up on our end with the custom field to give it a test. I suspect the issue with your code is that you are trying to set a variable column name ($tmp_doc_colum). Depending on your server setup, you might need single quotes around the variable name.
For this code:
$tmp_doc_type = $vars['data']['doc_doc_type'];
$tmp_doc_colum = prj_.$tmp_doc_type._nr;
$query = mysql_query("SELECT $tmp_doc_colum FROM ft_form_15 WHERE submission_id = $tmp_doc_prj_id AND is_finalized = 'yes'");
Try enclosing the variable with a backtick:
$tmp_doc_type = $vars['data']['doc_doc_type'];
$tmp_doc_colum = prj_.$tmp_doc_type._nr;
$query = mysql_query("SELECT `$tmp_doc_colum` FROM ft_form_15 WHERE submission_id = $tmp_doc_prj_id AND is_finalized = 'yes'");
Or you can try to break out the variable
$query = mysql_query("SELECT " . $tmp_doc_colum " FROM ft_form_15 WHERE submission_id = $tmp_doc_prj_id AND is_finalized = 'yes'");
Or
$query = mysql_query("SELECT `" . $tmp_doc_colum "` FROM ft_form_15 WHERE submission_id = $tmp_doc_prj_id AND is_finalized = 'yes'");
I would output the query to ensure you are actually getting the correct SQL query otherwise you really don't know if you're actually pulling data and producing the code you need. There can be a SQL error and you wouldn't even know it.
Cheers,
Joe
Thanks for the wait. We need to create a similar set up on our end with the custom field to give it a test. I suspect the issue with your code is that you are trying to set a variable column name ($tmp_doc_colum). Depending on your server setup, you might need single quotes around the variable name.
For this code:
$tmp_doc_type = $vars['data']['doc_doc_type'];
$tmp_doc_colum = prj_.$tmp_doc_type._nr;
$query = mysql_query("SELECT $tmp_doc_colum FROM ft_form_15 WHERE submission_id = $tmp_doc_prj_id AND is_finalized = 'yes'");
Try enclosing the variable with a backtick:
$tmp_doc_type = $vars['data']['doc_doc_type'];
$tmp_doc_colum = prj_.$tmp_doc_type._nr;
$query = mysql_query("SELECT `$tmp_doc_colum` FROM ft_form_15 WHERE submission_id = $tmp_doc_prj_id AND is_finalized = 'yes'");
Or you can try to break out the variable
$query = mysql_query("SELECT " . $tmp_doc_colum " FROM ft_form_15 WHERE submission_id = $tmp_doc_prj_id AND is_finalized = 'yes'");
Or
$query = mysql_query("SELECT `" . $tmp_doc_colum "` FROM ft_form_15 WHERE submission_id = $tmp_doc_prj_id AND is_finalized = 'yes'");
I would output the query to ensure you are actually getting the correct SQL query otherwise you really don't know if you're actually pulling data and producing the code you need. There can be a SQL error and you wouldn't even know it.
Cheers,
Joe