This topic is locked

Troubles with History

6/4/2012 1:24:34 AM
PHPRunner General questions
A
ashumak author

//** Save new data in another table ****

global $conn,$strTableName;
$strSQLSave = "INSERT INTO process_history (DBA_Name, step_completed, date_completed, completed_by, next_step) values (";
$strSQLSave .= $values[DBA_Name].",";

$strSQLSave .= $values[step_completed].",";

$strSQLSave .= $values[date_completed].",";

$strSQLSave .= $values[completed_by].",";

$strSQLSave .= $values[next_step];
$strSQLSave .= ")";

db_exec($strSQLSave,$conn);
Tried this in the Edit Page: Before record Updated.

Trying to send the data that has been entered into a seperate table to use as a history. No luck.
Suggestions?

C
cgphp 6/4/2012

You have to escape with a single quote the values. Try this version.

global $conn,$strTableName;
$strSQLSave = "INSERT INTO process_history (DBA_Name, step_completed, date_completed, completed_by, next_step) values ("';
$strSQLSave .= $values[DBA_Name]."','";

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

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

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

$strSQLSave .= $values[next_step]."')";
db_exec($strSQLSave,$conn);
A
ashumak author 6/4/2012



You have to escape with a single quote the values. Try this version.

global $conn,$strTableName;
$strSQLSave = "INSERT INTO process_history (DBA_Name, step_completed, date_completed, completed_by, next_step) values ("';
$strSQLSave .= $values[DBA_Name]."','";

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

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

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

$strSQLSave .= $values[next_step]."')";
db_exec($strSQLSave,$conn);



Thanks, but got Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING
Alan

C
cgphp 6/4/2012
global $conn,$strTableName;
$strSQLSave = "INSERT INTO process_history (DBA_Name, step_completed, date_completed, completed_by, next_step) values ('";
$strSQLSave .= $values[DBA_Name]."','";

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

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

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

$strSQLSave .= $values[next_step]."')";
db_exec($strSQLSave,$conn);
A
ashumak author 6/4/2012


global $conn,$strTableName;
$strSQLSave = "INSERT INTO process_history (DBA_Name, step_completed, date_completed, completed_by, next_step) values ('";
$strSQLSave .= $values[DBA_Name]."','";

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

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

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

$strSQLSave .= $values[next_step]."')";
db_exec($strSQLSave,$conn);



The syntax is right, but when I try to save the edited form, it doesn't do anything! No records are being sent to the table.

C
cgphp 6/4/2012

What are the database types of DBA_Name, step_completed, date_completed, completed_by and next_step ?

A
ashumak author 6/4/2012



What are the database types of DBA_Name, step_completed, date_completed, completed_by and next_step ?


DBA_Name, step_completed,completed_by and next_step - VARCHAR

date_completed - Date

C
cgphp 6/4/2012

Try to run the query directly from your database manager (i.e. phpmyadmin).

A
ashumak author 6/4/2012



Try to run the query directly from your database manager (i.e. phpmyadmin).


Not sure how to word it...the above didn't work....

C
cgphp 6/4/2012

Do you get errors in phpmyadmin?

A
ashumak author 6/4/2012



Do you get errors in phpmyadmin?


Yes, syntax errors...wasn't sure how to word it.

C
cgphp 6/4/2012

Paste the error here.

A
ashumak author 6/4/2012



Paste the error here.


Error

SQL query:
"INSERT INTO process_history (DBA_Name, step_completed, date_completed, completed_by, next_step) values ('";
MySQL said:

1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '"INSERT INTO process_history (DBA_Name, step_completed, date_completed, complete' at line 1