Weird things. Values did not inserted into the database.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
kingdm
Forum Commoner
Posts: 27
Joined: Thu Dec 03, 2009 9:32 am

Weird things. Values did not inserted into the database.

Post by kingdm »

Hello everyone.

I have a question. I'm using this code to insert my values into the database. I never had a problem on it until a while ago when I created my Edit module of licenses page in my project.

Here is snippet of the form:

licenses.php

Code: Select all

 
<form method="post" action="edit_licenses_verify.php">
        <label>Phil. License (PRC)
        <span class="small">license number</span>
        </label>
        <input type="text" name="prc_number" maxlength="50" value="<?php echo $_SESSION['prc_number']; ?>" />
        
        <label>Rank
        <span class="small">rank in PRC license</span>
        </label>
        <input type="text" name="prc_rank" maxlength="50" value="<?php echo $_SESSION['prc_rank']; ?>" />
</form>
 
The $_SESSION in the value attribute is already fetch upon the login. There is no problem with that because it displays the current value for prc_number and prc_rank of the user. (because this is an edit module)

edit_licenses_verify.php

Code: Select all

 
$con = mysql_connect("localhost","","") or die(mysql_error());
$db = mysql_select_db("mytable_project_dbase",$con);
 
$_SESSION['prc_number'] = cleanString($_POST['prc_number']);
$_SESSION['prc_rank'] = cleanString($_POST['prc_rank']);
 
$db_prcnumber = $_SESSION['prc_number'];
$db_prcrank = $_SESSION['prc_rank'];
.
.
.
// then some other codes and validations
.
.
.
if(count($errors) > 0)
{
    //displays errors
}
 
else
{
    //update database if no error, this is the part where I think must be the problem
 
   $sql_change = "UPDATE users SET `prc_number`='$db_prcnumber,`prc_rank`='$db_prcrank',`prc_mbday`='$db_prcmbday',`prc_dbday`='$db_prcdbday',`prc_ybday`='$db_prcybday',`marina_number`='$db_marinanumber',`marina_rank`='$db_marinarank',`marina_mbday`='$db_marinambday',`marina_dbday`='$db_marinadbday',`marina_ybday`='$db_marinaybday',`sirb_number`='$db_sirbnumber',`sirb_mbday`='$db_sirbmbday',`sirb_dbday`='$db_sirbdbday',`sirb_ybday`='$db_sirbdybday',`sirc_number`='$db_sircnumber',`sirc_rank`='$db_sircrank' WHERE id='".$_SESSION['id']."'";
 
   $result=mysql_query($sql_change);
}
 
I pasted my whole UPDATE query, that is the table on the database and the values. My problem is I always used this since the beggining, but why now it won't insert into the database anymore. the prc_number and prc_rank in the table value won't change based on the input I placed on the form.

Can someone help me regarding this? Hoping for your kind assist. Thank you.
kingdm
Forum Commoner
Posts: 27
Joined: Thu Dec 03, 2009 9:32 am

Re: Weird things. Values did not inserted into the database.

Post by kingdm »

Resolved. Finally got it working, after I placed a die() on my sql query. A missing ' in the query.
Post Reply