You are here: Problem Getting MS SQL Data With Single Quotes « PHP SQL « IT news, forums, messages
Problem Getting MS SQL Data With Single Quotes

Posted by Eddie on 09/13/07 19:35

I'm having difficulty getting data out of MS SQL Server via a PHP
database call. When I look in the database, it crashes on the line
where there is a single quote in the database. I've seen several
articles about addslashes/stripslashes and str_replace for MS SQL.
Had the data been put in the right way, there would be no problem.
Or, if I had rights to use UPDATE/SET to modify all lines with single
quotes, again there would be no problem. The problem is there is no
way for me to change the data already stored in MS SQL. I can only
read it, and IT won't let me change it. (Gotta love corporate
America, but I digress). So now that the data is there, how can I
retrieve it when it has a single quote in the data? Am I missing
something? Please help.

=====
Query sample:

$query1 = "SELECT * FROM table WHERE Name = '" .
addslashes($name) ."' ";
$result1 = db_query($query1, $DBLink) or die ('Error: Database
error !');
while ($row1 = db_fetch_assoc($result1)) {
echo ( ($k++ == 0) ? (stripslashes($row1['WCUSNO'])) :
("," . stripslashes_mssql($row1['WCUSNO'])) );
}

=====
Data sample (Name):

John Doe
John Q Public
Tom's Bait Shop <---- This is where it dies, due to the
apostrophe / single quote

Thanks for your help.

Eddie

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация