> What's wrong with this PHP Mysql codes... it cannot perform the update...?

What's wrong with this PHP Mysql codes... it cannot perform the update...?

Posted at: 2014-12-18 
I'm wrecking my head trying to think of a reason why somebody would set all fields of a row to the name of the column, but I'm drawing a huge blank. What's the point of this UPDATE query? Is there any rhyme or reason to doing this?

I can imagine lots of reasons why this query fails, what exactly are you trying to achieve here? I don't think it's reasonable to try an fix this; there should be a much better way to do this.

First of all there probably will be a WHERE clause after that, like this: WHERE something_id=6;

I'm guessin you want to modify a specific row with a specific something_id(primary key).

Then you should use CONSTANTS not variables for the mysql_connect parameters. Why are you using quotes there anyway?

$conex = mysqli_connect($host, $username, $pass, $dbname); //Connection to db

// That $sql thingy, but this time done right

$upd = mysqli_query($conex, $sql); // the actual query sent to mysql

if ($upd) {echo 'Yay!'} // if you're just playing around and want to check if it worked though it should work ... but I'm quite new to PHP and I might have missed something somewhere out of hurry.

Hello!

Where is the end of the query?

codes here...


$host="localhost"; // Host name

$username="root"; // Mysql username

$password="1003"; // Mysql password

$db_name="registration"; // Database name

$tbl_name="cenrolled"; // Table name

$idsem = $_POST["idsem"];

// Connect to server and select database.

mysql_connect("$host", "$username", "$password")or die("cannot connect");

mysql_select_db("$db_name")or die("cannot select DB");

// update data in mysql database

$sql="UPDATE $tbl_name SET `tuitionfee` = 'tuitionfee',

`guidancefee` = 'guidancefee',

`lib_id_cardfee` = 'lib_id_cardfee',

`culturalartsfee` = 'culturalartsfee',

`libfee` = 'libfee',

`exservicesfee` = 'exservicesfee',

`schoolpaperfee` = 'schoolpaperfee',

`athleticsfee` = 'athleticsfee',

`avfee` = 'avfee',

`apscufee` = 'apscufee',

`charitablefee` = 'charitablefee',

`otherfee` = 'otherfee',

`medicalfee` = 'medicalfee',

`othercharge1remarks` = 'othercharge1remarks',

`othercharge1fee` = 'othercharge1fee',

`nstpfee` = 'nstpfee',

`othercharge2remarks` = 'othercharge2remarks',

`othercharge2fee` = 'othercharge2fee',

`registrationfee` = 'registrationfee',

`labfee` = 'labfee',

`totalfee` = 'totalfee',

`discountfee` = 'discountfee',

`otherlessremarks` = 'otherlessremarks',

`otherlessfee` = 'otherlessfee',

`netfee` = 'netfee',

`cash` = 'cash',

`orcash` = 'orcash',

`cashdate` = 'cashdate',

`grandtotalfee` = 'grandtotalfee',

`dpfee` = 'dpfee',

`ornumberdp` = 'ornumberdp',

`dpdate`