Current location: Hot Scripts Forums » Programming Languages » PHP » Special Character Problem


Special Character Problem

Reply
  #1 (permalink)  
Old 02-24-04, 10:25 PM
Greggory Greggory is offline
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
Reply With Quote
  #2 (permalink)  
Old 02-25-04, 06:39 AM
the_mole001's Avatar
the_mole001 the_mole001 is offline
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.
Reply With Quote
  #3 (permalink)  
Old 02-25-04, 09:45 AM
<?Wille?> <?Wille?> is offline
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:
PHP Code:

$Parent htmlspecialchars('$Parent'); // if doesint work.. try other quotes. not shoure its ' 

hope it helps
Reply With Quote
  #4 (permalink)  
Old 02-25-04, 04:06 PM
AccelEric AccelEric is offline
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.
Reply With Quote
  #5 (permalink)  
Old 02-25-04, 04:15 PM
Greggory Greggory is offline
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.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
php in linux problem usman PHP 6 05-15-04 11:57 AM
User Authentication and Session problem!!! askme PHP 1 02-06-04 09:10 AM
Problem with slashes in forms startanisp PHP 3 02-02-04 07:03 AM
Typing special chars without numeric keypad? wilson@cpuworks.com The Lounge 3 01-06-04 05:22 PM
Error: Syntax error converting datetime from character string. Han84 ASP 1 08-22-03 04:59 AM


All times are GMT -5. The time now is 09:04 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.