Update Query

5 posts by 2 authors in: Forums > CMS Builder
Last Post: April 15, 2009   (RSS)

Re: [rjbathgate] Update Query

By Dave - April 14, 2009

Hi Rob,

What do these two debug lines output?

<xmp><?php print_r($_POST); ?></xmp>

and

<xmp><?php print_r($updateQuery); ?></xmp>

Once we can see what is being submitted by the form and the query that is being sent to MySQL it should make it easier to isolate and resolve the issue.

Also, you can write this:
updatedDate = '".mysql_real_escape_string( $currentDate )."',

as this:
updatedDate = NOW(),

Since we now update the timezone for mysql as well.

Hope that helps, let me know what you find.
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] Update Query

Hey Dave,

Thanks for the quick reply.

The output for the _POST print is working fine, but looking at the updateQuery output, we see:

UPDATE `cms_directory_listing` SET company = 'Development Company Test', updatedDate = '2009-04-15 04:51:15', updatedByUserNum = '' WHERE num = ''

You'll see the last two fields (updated by and where num) are both blank. So they're not getting populated...

This is the code for them:
updatedByUserNum = '" .mysql_real_escape_string($currentloggednum). "'
WHERE num = '" .mysql_real_escape_string($currentprofilenum). "'";


These two variables are correctly defined before they are called...

So have I got this string written incorrectly:
updatedByUserNum = '" .mysql_real_escape_string($currentloggednum). "'
WHERE num = '" .mysql_real_escape_string($currentprofilenum). "'";


??

Just tried:
updatedByUserNum = '"$currentloggednum"'
WHERE num = '"$currentprofilenum"'";


but that doens't work...!

Cheers

Re: [rjbathgate] Update Query

By Dave - April 15, 2009 - edited: April 15, 2009

Great, we're narrowing down the cause. Getting it to put those values in a query and passing it to mysql is pretty close to just printing them. So see if you can get them to print out, out print out the whole query with them.

Try this debug code on the line before: $updateQuery = ...

print "<xmp>";
print "\$currentloggednum = '$currentloggednum'\n";
print "\$currentprofilenum = '$currentprofilenum'\n";
print "</xmp>";

Let me know what that says.

And feel free to attach the whole script if you can.
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] Update Query

Cracked it!

The variables were defined correctly on the pre-form-submit, but once the form was submit (back onto itself) the variables were lost, and coming back as blank.

So but putting the variables into the form as hidden fields and then redefining them from that, it's all working now.

Thanks heaps Dave - all your debug code is a great help

Rob