php-windows Digest 4 Apr 2004 09:32:21 -0000 Issue 2194
Topics (messages 23360 through 23361):
Re: quotes in mysql
23360 by: Luiz Miguel Axcar
SOLVED: Re: Update multiple records from a text field
23361 by: kaizer boab
Administrivia:
To subscribe to the digest, e-mail:
[EMAIL PROTECTED]
To unsubscribe from the digest, e-mail:
[EMAIL PROTECTED]
To post to the list, e-mail:
[EMAIL PROTECTED]
----------------------------------------------------------------------
--- Begin Message ---
Hello,
> insert into table_name (describe) values('" . $check . "')
I think it work:
$data = addslashes ($_POST ['data']) //adding slashes before special chars
// take a look on manual to get info about get_magic_quotes_gpc () to do not
add slashes in a string with slashes
$query = "INSERT INTO table_name (field) VALUES ('$data')";
//exec query
[]'s
Luiz Miguel Axcar
lmaxcar AT yahoo DOT com DOT br
((( i ))) Campinas, São Paulo, Brasil
http://www.geocities.com/lmaxcar
PHP [enguin] never sleeps.
----- Original Message -----
From: Sudeep Sarath <[EMAIL PROTECTED]>
To: Php-windows mailing list <[EMAIL PROTECTED]>
Sent: Friday, April 02, 2004 6:16 AM
Subject: [PHP-WIN] quotes in mysql
> Hi friends,
>
> I have a 'textarea' in my php page and i need to put the details typed in
that textarea box to my MySQL database. The content in the textarea box
is(for example) : I'm a good boy.
>
> and insert string is:
>
> insert into table_name (describe) values('" . $check . "')
>
> where check is the variable that stores the POST data of textarea. Also
the field "describe" is of a text datatype.
>
> what happens is that i can't take the content string to the database.
B'cause it contains I'm (a single quote in between I and m) which confuses
mySql that string terminates after I. Is there any solution for this problem
as we cannot tell the users "dont put quotes in textarea".
>
> ....SuDeEp...
>
> Win an evening with the Indian cricket captain: Yahoo! India Promos.
--- End Message ---
--- Begin Message ---
Thanks Justin and Khashan for all your help.
Managed to resolve the issue. I named qty field using the albumId as key and
using qty as value.
All I had to do then was update the query in the while loop.
"Kaizer Boab" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Hi everybody,
>
> I have built a shopping cart using tables. I am able to add items and
remove
> items from the cart. The problem I am having is updating the quantities in
> the cart.
>
> When users view the cart they can see the quantity in a text field. I want
> to allow users to type in the quantities they want in this box and then
> submit the form to display the new quantities.
>
> The problem is when the form is submitted only one of the quantity fields
is
> updated, the others remain unchanged. I have tried to use a while loop to
> make it update all the quantities but it doesn't seem to work. Below is
the
> script I am using to UPDATE the quantites. Can anyone help me?
>
> Thanx in advance.
>
>
> <?php
> $trackerId = $HTTP_POST_VARS['trackerId'];
> $albumId = $HTTP_POST_VARS['albumId'];
> $qty = $HTTP_POST_VARS['qty'];
>
> mysql_select_db($database_con_ayrsrock, $con_ayrsrock);
>
> $queryQty= "SELECT qty FROM cart WHERE trackerId = $trackerId AND albumId
=
> $albumId";
> $rsQty = mysql_query($queryQty);
>
> while ($row_rsQty = mysql_fetch_array($rsQty))
> {
> $newQty = $qty;
> mysql_query("update cart set qty = $newQty where trackerId = $trackerId
and
> albumId = $albumId");
> }
> ; ?>
--- End Message ---