Special Character Problem

02-24-04, 10:25 PM
|
|
New Member
|
|
Join Date: Feb 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
|
Special Character Problem
Every time I try to update a record in one of my tables where the entry contains the character ', I get the error could not update the Page table. I tried updating the same record with phpMyAdmin and everything works fine. Is there something I need to add to my sql to allow this character? Below is a copy of my update sql.
$PageUpdate = "UPDATE Page
SET
Parent = '$Parent',
ViewLevel = '$ViewLevel',
PropertyID = '$PropertyID',
Priority = '$Priority',
PublishStatus = '$PublishStatus',
Hits = '$Hits',
CounterStyle = '$CounterStyle',
PageTitle = '$PageTitle',
Keywords = '$Keywords',
Description = '$Description',
Template = '$Template'
WHERE PageID = '$PageID'
";
$PageUpdateResult = MYSQL_QUERY($PageUpdate,$connection)
OR DIE("Could not update the Page table.");
Thanks In Advance,
Greggory
|

02-25-04, 06:39 AM
|
 |
Newbie Coder
|
|
Join Date: Feb 2004
Location: Australia
Posts: 96
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hello Greggory,
I don't know if you copied the code properly or this is the mistake but you are missing a "," after Template = '$Template' so i think this might fix your code:
$PageUpdate = "UPDATE Page
SET
Parent = '$Parent',
ViewLevel = '$ViewLevel',
PropertyID = '$PropertyID',
Priority = '$Priority',
PublishStatus = '$PublishStatus',
Hits = '$Hits',
CounterStyle = '$CounterStyle',
PageTitle = '$PageTitle',
Keywords = '$Keywords',
Description = '$Description',
Template = '$Template',
WHERE PageID = '$PageID'
";
$PageUpdateResult = MYSQL_QUERY($PageUpdate,$connection)
OR DIE("Could not update the Page table.");
I hope this works out, forgetting something as simple as a "," can be a real pain.
|

02-25-04, 09:45 AM
|
|
Junior Code Guru
|
|
Join Date: Jan 2004
Location: Helsinki, Finland
Posts: 666
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
you say its special chars..
try with running all var trough htmlspecialchars() before putting them together..
like:
hope it helps
|

02-25-04, 04:06 PM
|
|
Newbie Coder
|
|
Join Date: Feb 2004
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Quote:
|
Originally Posted by the_mole001
Hello Greggory,
I don't know if you copied the code properly or this is the mistake but you are missing a "," after Template = '$Template' so i think this might fix your code:
$PageUpdate = "UPDATE Page
SET
Parent = '$Parent',
ViewLevel = '$ViewLevel',
PropertyID = '$PropertyID',
Priority = '$Priority',
PublishStatus = '$PublishStatus',
Hits = '$Hits',
CounterStyle = '$CounterStyle',
PageTitle = '$PageTitle',
Keywords = '$Keywords',
Description = '$Description',
Template = '$Template',
WHERE PageID = '$PageID'
";
$PageUpdateResult = MYSQL_QUERY($PageUpdate,$connection)
OR DIE("Could not update the Page table.");
I hope this works out, forgetting something as simple as a "," can be a real pain.
|
you didn't read it right, he did that right, he doesn't need a coma after $template.
If I were you, I'd check and make sure the var PageID has something in it and something is getting put in there ect.. if not, then it won't work. and do this...
OR DIE(mysql_error()); to get a more detailed error. It will help you locate the problem, I bet it can't find the collumn $PageID, because it wasn't inputed correctly, but other then that, I don't know what's wrong.
|

02-25-04, 04:15 PM
|
|
New Member
|
|
Join Date: Feb 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I know the sql is correct (with the exception of special characters) because if I update a record without using the ' character or escape it as such /' everything works fine.
This is the query I use to populate the form before the update:
$PageQuery = "SELECT *
FROM Page
WHERE PageID = '$PageID'
";
$PageQueryResult = mysql_db_query($database,$PageQuery);
while ($row = mysql_fetch_array($PageQueryResult))
{
$PageID = $row['PageID'];
$ViewLevel = $row['ViewLevel'];
$PropertyID = $row['PropertyID'];
$Priority = $row['Priority'];
$Parent = $row['Parent'];
$PageTitle = $row['PageTitle'];
$Keywords = $row['Keywords'];
$Description = htmlspecialchars(($row['Description']));
$Template = $row['Template'];
$PublishStatus = $row['PublishStatus'];
$Hits = $row['Hits'];
$DateCreate = $row['DateCreate'];
$CounterStyle = $row['CounterStyle'];
}
The funny thing is this works fine on one server and not on another.
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|