php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #4964 inserting "special" data fails
Submitted: 2000-06-11 21:31 UTC Modified: 2000-06-11 22:48 UTC
From: fredo at pandora dot be Assigned:
Status: Closed Package: ODBC related
PHP Version: 4.0.0 Release OS: NT4/Apache1.3.12
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: fredo at pandora dot be
New email:
PHP Version: OS:

 

 [2000-06-11 21:31 UTC] fredo at pandora dot be
Ok, here goes, I don't think this is a real bug, but I can't find a solution for it,

$db_query  = "INSERT INTO UserInfo (Name, Email) ".
             "VALUE ('$username', '$email')";
$db_result = odbc_exec($db_conn, $db_query);

This works smoothly as long as no value contains a "special" sign. Example,

$username="Olivier D'hooghe"

Several people told me to use addslashes() but that doesn't solve it, here follows the error message,

Warning: SQL error: [Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression ''Olivier D\'Hooghe', 'oli@home.net')'., SQL state 37000 in SQLExecDirect in common.php on line 101

The problem is the <'> in the username. I'm stuck.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-06-11 22:27 UTC] stas at cvs dot php dot net
This is not PHP error. Try finding how Access escapes quotes (double quote?)
 [2000-06-11 22:48 UTC] fredo at pandora dot be
<?
  $username = "Olivier D'hooghe";
  $username = ereg_replace("'", "''", $username);
  echo $username;
?>

Solves it...
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri May 17 05:01:31 2024 UTC