/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] Weird things. Values did not inserted into the database.

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=php]
<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>
[/code]

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=php]
$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);
}
[/code]

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.

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@chris22Dec 30.2009 — Hi, I would suggest changing your last line from:

[code=php]
$result=mysql_query($sql_change);
[/code]


to:

[code=php]
$result=mysql_query($sql_change) or die("Query failed: ".mysql_error());
[/code]


This way you might be able to spot some error.
Copy linkTweet thisAlerts:
@kingdmauthorDec 30.2009 — Definitely right chris22. Just what I did a while ago, it spotted the error, and the error was meaningly a missing ' in the query. ?

Thanks for dropping by a reply on my question.
×

Success!

Help @kingdm spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.6,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...