This topic is locked
[SOLVED]

 insert date in another table

5/31/2011 7:22:19 AM
PHPRunner General questions
M
maxcolo author

Hi,

I have two table
prestazioni_avute

id_prestazione

codicesocio

prestazione_data

ore

beneficiario

data
prestazioni_date

id_prestazione

codicesocio

prestazione_data

ore

beneficiario

data
in the add page of prestazioni_avute I would like to add before add the same record in the another table prestazioni_date.

My sequence is
[color="#000088"]global $conn
$strSQLSave [color="#666600"].= $values
$strSQLSave [color="#666600"].= $values
$strSQLSave [color="#666600"].= $values
$strSQLSave [color="#666600"].= $values;

[color="#000000"]$strSQLSave
$strSQLSave
db_exec[color="#666600"]($strSQLSave
[color="#000088"]return ;I get an error and I can not answer, someone please help me understand?

Sorry for my english I am Italian

Best Regards at all

Max
I get an error and I can not answer, someone please help me understand?

Sorry for my english

Max

L
Lena 5/31/2011

Hi,

there are syntax errors in your code: you've set a unnecessary comma and a opening bracket in the code.

Also you've missed a comma in this line:

$strSQLSave .= $values['beneficiario'];



Please find updated code:



global $conn,$strTableName;

$strSQLSave = "INSERT INTO tavoli_pranzo (codicesocio, prestazionedata, ore, beneficiario, data) values ('";

$strSQLSave .= $values['codicesocio']."','";

$strSQLSave .= $values['prestazionedata']."','";

$strSQLSave .= $values['ore']."','";

$strSQLSave .= $values['beneficiario']."','";

$strSQLSave .= $values['data'];

$strSQLSave .= "')";

db_exec($strSQLSave,$conn);

return true;


Also to debug code we recommend to print executed query on the page:

echo $strSQLSave;



Then run this SQL in the database (usign any MySQL administrative tool) and correct it if needed.