This my first post on this site. I will do my best to include all the needed information. I have read many of the answers regarding this same problem. I have tried many combinations and none of them work. The following is the one that gets me the closest to my very simple goal --> Write a line to my database. This code is in a password protected portion of my site.
<?php
//Connect to database
include("../ConfigFiles/ConnectDB_live.php");
echo "<br> I am still alive? <br>";
//Can I read from DB --- This worked on live
$strSQL = "SELECT * FROM invoicelist_table";
$rs = mysql_query($strSQL);
while($row = mysql_fetch_array($rs))
{
echo $row['FileName'] . "<br>";
}
//Can I write to the DB --- Live
//Lets mix a few ideas together
mysql_query($bdd,"INSERT INTO `invoicelist_table` (`InvoiceNo`, `FileName`, `FilePath`) VALUES ('9999', 'MyName', 'MyPath')") ;
echo mysql_error();
//or die(mysql_error());
echo "I wrote something to the DB successfully <br>";
// Close the database connection
mysql_close();
echo "The connection to DB is closed";
?>
Note that I can read the database just fine but I can't seem to write to it. I have also tried the recommended mysqli version but that does not work either. I have tried various ways of trapping an error and I get nothing... literally nothing! I have tried at least a dozen syntax variations. I am ready to throw up!
I am new to web programming and find most of my answers online. I think I am doing pretty good for my limited knowledge. This one is blowing my mind. None of the recommendations I read about work or make sense to me. So please answer me like I am a 5-yr old!
Thanks in advance.
Move your connection as the second parameter or remove it if you didnt close the connection
mysql_query("INSERT INTO `invoicelist_table` (`InvoiceNo`, `FileName`, `FilePath`) VALUES ('9999', 'MyName', 'MyPath')") ;