PDA

View Full Version : What is wrong with this query?


TheMayhem
08-10-2004, 01:21 AM
I'm trying to custom write a user title color hack and I almost got it... However when the page loads online and I update the settings for some reason it's not making changes to the database row in the user table which is called titlecolor.

// ############################### Edit Title Color ###############################

if ($_REQUEST['do'] == 'edittitlecolor')
{
$templatename = 'titlecolor';
}

// ############################### Update Title Color ###############################

if ($_POST['do'] == 'updatetitlecolor')
{
globalize($_POST, array('titlecolor' => STR));

// Support tags HTML grog6
$titlecolor = strip_tags($titlecolor);


$DB_site->query("
UPDATE " . TABLE_PREFIX . "user SET
titlecolor = '" . addslashes($titlecolor) ."'
WHERE userid = $bbuserinfo[userid]
");

echo "titlecolor";

$url = "usercp.php?$session[sessionurl]";
eval(print_standard_redirect('redirect_updatethank s'));

}

Colin F
08-10-2004, 04:14 AM
good question...

do you have global.php required?
And do you make sure somewhere, that the user is logged in? (not that $bbuserinfo[userid] is empty)
are you getting any error messages anywhere?

Modin
08-10-2004, 04:32 AM
add echo statements to see if it's actually getting the variable. (I notice you're missing the $ in your echo statement)

Other than that the code looks fine, so I would say it's on the html form side of the script.

TheMayhem
08-10-2004, 03:39 PM
Script's going through and I just used that echo statement as an example. I edited a row on my user in phpmyadmin and like changed the "titlecolor" to silver... went online on the page it was there and it showed silver, I then changed it to white and clicked save and then it went back to being blank where $usertitle should of been. So for some reason it's not saving through the database as text *shrugs*

Modin
08-10-2004, 04:16 PM
$titlecolor is probably not being set.

post the html of your form that submits to script, the problem is probably in there.

Dean C
08-10-2004, 04:17 PM
Can you format you code with tabs to make it a little easier for us to read :)?

TheMayhem
08-10-2004, 11:14 PM
Okay here's the complete non working script. ;)

Under the template definitions at the top of profile.php I have added this...

'edittitlecolor' => array(
'titlecolor',
),


Then I have what I listed at the top of this page...

And to finish it off I have this template...

<form action="profile.php" method="post">
<input type="hidden" name="s" value="$session[sessionhash]" />
<input type="hidden" name="do" value="updatetitlecolor" />

<table class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" border="0" width="100%" align="center">
<tr>
<td>

<fieldset class="fieldset">
<legend>Update User Title Color</legend>
<table cellpadding="0" cellspacing="$stylevar[formspacer]" border="0" width="100%">
<tr>
<td><smallfont>Enter the color of what you would like your User Title Color to appear on posts.</smallfont>
<div>
<textarea name=font rows=1 cols=30>$bbuserinfo[titlecolor]</textarea>
</div> </td>
</tr>
</table>
</fieldset>

</td>
</tr>
<tr>
<td>


<div style="margin-top:$stylevar[cellpadding]px">
<input type="submit" class="button" value="$vbphrase[save_changes]" accesskey="s" />
<input type="reset" class="button" value="$vbphrase[reset_fields]" accesskey="r" />
</div>
</td>
</tr>
</table>

</form>