Hi all
My function below attempts to insert values into db table. The table is never updated and mysql returns no errors. The table itself remains empty.
I have found many proposed solutions for similar situations (including in this forum), but none of them have helped. For example, using back ticks instead of single quotes around the values, INSERT might be sending empty values, values might not be reaching the function - along with a few other suggested fixes which didn’t work.
Unfortunately, I don’t have direct access to the db. So, I’m taking the clients word that the table is empty, she seems to know what she’s doing, I don’t have any reason to doubt what she says.
Can anyone throw some new light on this for me - thanks
function store_details($db_server, $db_user, $db_pass, $db_name, $ftp_server, $subject, $skipfile, $skipdir, $rename_file, $alert, $from, $message, $createLog, $cronlogpath){
$date = date ("dMy");
$time = date("H:i");
$site_table = 'ssa_'.str_replace('-','$',str_replace('.','_',$ftp_server)).'_site';
$con = mysql_connect($db_server,$db_user,$db_pass)or die('Unable to connect to MySQL server: '.$db_server.'<br>Please check that the following details are correct:<br>
db server name<br>
db user name<br>
db password<br>
<a href="index1.php?check_db_details=Y">Click to reload form</a>');
mysql_select_db($db_name, $con)or die('Connected but, unable to select db! '.mysql_error());
$query = "TRUNCATE TABLE $site_table";
mysql_query($query)or die('Failed to empty site table<br>'.mysql_error());
$query ="INSERT INTO $site_table (
email_subj,
email_alert,
skip_files,
skip_dir,
from_addr,
email_header,
cron_path,
rename_file,
SSA_log,
date,
time
)
VALUES (
'$subject',
'$alert',
'$skipfile',
'$skipdir',
'$from',
'$message',
'$cronlogpath',
'$rename_file',
'$createLog',
'$date',
'$time')";
mysql_query($query) or die('Failed to update site table. Mysql returned the following:<br><br>'.mysql_error());
mysql_close($con)or die(mysql_error());
}