Re: MySQLand a prepared statement problem
| From: | Jason Carson | Date: | Fri, 17 Jul 2009 03:55:49 +0000 |
| Subject: | Re: MySQLand a prepared statement problem | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-46328@lists.php.net to get a copy of this message | ||
> Hello everyone,
>
> I have a problem. When I insert <a
> href="http://example.com>Example</a>
> into my database with the following code...
>
> $connect = mysqli_connect($hostname, $username, $password, $database);
> $sql="INSERT INTO notes VALUES ('$id', '$note')";
> $result=mysqli_query($connect, $sql);
>
> ...everything works fine. The link (when I SELECT it and display it in my
> browser) works as one would expect.
>
> However when I insert <a href="/qÿ)
> 4o"Ý(1À"¬ahttp://example.com">Example</a> into my
> database with the following code (prepared statement)...
>
> $submitnote = mysqli_prepare($connect, "INSERT INTO notes VALUES (?, ?)");
> mysqli_stmt_bind_param($submitnote, "is", $id, $note);
> mysqli_stmt_execute($submitnote);
>
> ...the link (when I SELECT it and display it in my browser) shows up as...
>
> http://jasoncarson.ca/admin/\"http://example.com\"
>
> ...Anyone know how to fix this so I can use the prepared statement?
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
Just to clarify, $id would be different for each entry in the database.
$id=1 or 2 or 3 etc...
and
$note = <a href="http://example.com">Example</a>