php tutorials, php form validation
Archive Tutorials
Discussion Home
Login / Register

Board List
PHP programming
General

Links
How to save gas 25% or more
Marshall Reddick
Network Marketing Forums
Income Tax Help
Lose 10 Pounds in 3 Weeks
PHP Forum Script
Online Contest

Learn PHP in 47 hours!

Back to General

Search

can't get single quotes in MS access can't get single quotes in MS access

can't get single quotes in MS access

by drpoll on Thu 08/10/2006 02:19 AM

Hi there, 

I'm very new with PHP and havong troubles with single quotes when I try to write them to a ms access database.  

This is my test code so far. It all works if the single quote is removed from $test. 

<?php
$test = "arjan'pollski"; 

$conn=odbc_connect('starmakertest2','','');
if (!$conn)
  {exit("Connection Failed: " . $conn);}
$sql="UPDATE starmaker1test SET ID = '$kommatest' WHERE Id1 = 383";
$rs=odbc_exec($conn,$sql);
if (!$rs)
  {exit("Error in SQL");}
?>

[Reply] [Back to Top]

extra info

by drpoll on Thu 08/10/2006 02:21 AM

I've been working with addslashes etc but the db still doesnt take it, while there are slashes added to the string when I did that. 

I hope someone knows a solution to my problem. 

Thanx in advance 

Arjan

[Reply] [Back to Top]

hardcode the string into $test

by uclaboyz on Thu 08/10/2006 05:57 PM

Hi Arjan, 

Have you tried putting a slash before the ' into $kommatest? 

For example, does the DB return error when you set 

$kommatest='It\'s a fine day';

[Reply] [Back to Top]

the solution

by drpoll on Fri 08/11/2006 12:02 AM

I, ve found the solution to my problem.  

here it is... 

<?php
$newtest = str_replace("'","’",$_POST[kortenaam]);  

$conn=odbc_connect('starmakertest2','','');
if (!$conn)
  {exit("Connection Failed: " . $conn);}
$sql="UPDATE starmaker1test SET ID = '$newtest' WHERE Id1 = $_POST[idnummer]";
$rs=odbc_exec($conn,$sql);
if (!$rs)
  {exit("Error in SQL");} 

echo "$_POST[kortenaam]";
?> 

This strips the $string from its qoute and replaces it with it's html entity. Maybe a "russian" solution but it works

[Reply] [Back to Top]

© Copyright 2006-2007.  All Rights Reserved. Site hosted by Small Business Web Design
how to start a blog | parenting tips website | Passive Income | baby websites