Re: PHP + Access + SQL Help!

From: Date: Mon, 22 Jul 2002 19:56:53 +0000
Subject: Re: PHP + Access + SQL Help!
References: 1  Groups: php.windows 
Request: Send a blank email to php-windows+get-14876@lists.php.net to get a copy of this message
try addcslashes(string str, string charlist). -- Best regards, George Nicolae IT Manager ___________________ PaginiWeb.com - Professional Web Design www.PaginiWeb.com "Dewey Williams" <williams@email.uncc.edu> wrote in message news:33767DC23FBEA24D85477AF57572420506626991@email.uncc.edu... > I am new to PHP but not programming. I have created a simple program to get > info from a form and put it into an Access database. Moving to a different > database like MySQL is NOT an option! > > Everything works fine unless the user puts a single quote (') in one of the > form text boxes. If they do, an ODBC error is generated and my SQL > statement doesn't work. > > I know this has to do with the way PHP handles quoting, and I have tried > addslashes, magic-quotes on/off, and other methods to solve this problem, > with no solution. > > Here are my specs: > Windows 2000 > Access 2000 > PHP 4.2.1 > magic-quotes (all) = Off > > Here is the short version of my code. Please let me know where the problem > is and how to solve it. > > <html> > <body> > > <?php > $FName = $_POST['FName']; > $LName = $_POST['LName']; > > $db = odbc_connect("MyData", "", ""); > > $str_AddRecord = "INSERT INTO Alumni ([FirstName], [LastName]) VALUES > ('$FName', '$LName')"; > > if (!$resp_AddRecord = odbc_exec($db, $str_AddRecord)){ > echo "Query error! ODBC error: ", odbc_errormsg(); > } else { > print("<p class='message'>Record Posted!</p>"); > } > > odbc_close($db); > > ?> > > </body> > </html> > > TIA > > Dewey Williams > williams@email.uncc.edu

« previous php.windows (#14876) next »