Puzzled on why this won't work

I am writing a very simple upgrade script that adds a field in the sales table of my programs database. The code runs fine without error, but does not add the field in the sales table. I have echoed the query and then copied that text and pasted it into phpmyadmin, and it worked fine, I just don’t know why it won’t work in the code.


<?php include ("../../settings.php"); if(isset($_GET['process'])) { $conn = mysql_connect("$server", "$username", "$password") or die("Could not connect : " . mysql_error()); mysql_select_db($cfg_database,$conn); $upgradetable=$cfg_tableprefix.'sales'; $query="ALTER TABLE $upgradetable ADD comment VARCHAR(100) NOT NULL AFTER sold_by"; mysql_query($query,$conn); echo 'PHP Point Of Sale's database has been successfully upgraded to version 7.2, please delete the upgrade and install folders for security purposes.'; } else { ?>

Clicking submit will upgrade the database to version 7.2, no data will be lost from the database.

<?php } ?>


I would start by echoing mysql_error()

If that doesn’t show an error then I’m not sure where to start.

Lot of help I am

Found the stupid error, when I was connecting to database I used the wrong varialbe $server $username, $password (they were $cfg_server, $cfg_username,$cfg_password)

Thanks for the echo of mysql_error();

Sponsor our Newsletter | Privacy Policy | Terms of Service