quotes problem....

General discussions related to php

Moderators: macek, egami, gesf

CrustyDOD
New php-forum User
New php-forum User
Posts: 13
Joined: Tue Oct 29, 2002 2:58 am

quotes problem....

Postby CrustyDOD » Mon May 12, 2003 12:43 pm

Hi

I have some problems with quotes...

I have 3 pages:
1st page is where i fill out a form and submit it
2nd is the preview page
3rd inserts data to database

now the problem is when i on 1st page enter text into editbox let's say:

some text "what" is this?

then i submit this data and on 2nd page i put this text
into hidden type field, the result is:

some text \

oki so i fixed this with stripslashes and i get
on second page then:

some text "what" is this?

yes this is what i want but when i submit this hidden field
to 3rd page, i get either:

some text \\ (using stripslashes)
or
some text (using just _post)

each time it clears off the text after "

how to fix this??

help needed

User avatar
Oleg Butuzov
Last Samuray
Last Samuray
Posts: 831
Joined: Sun Jun 02, 2002 3:09 am

Postby Oleg Butuzov » Mon May 12, 2003 9:07 pm

1st page simple form
2nd page
echo stripslashes($_POST['msg'])
3rd page
$msg=addslashes("$_POST[msg]");
INSERT INTO `base` (`coll`) VALUES ('$msg')

CrustyDOD
New php-forum User
New php-forum User
Posts: 13
Joined: Tue Oct 29, 2002 2:58 am

Postby CrustyDOD » Mon May 12, 2003 11:26 pm

Hi

i tried your way, but it still cuts off words.
i used: test "a"
and i got: test :evil:

any other idea?

andrewdavey
New php-forum User
New php-forum User
Posts: 16
Joined: Wed Feb 12, 2003 5:27 am
Location: Cornwall, England

Magic Quotes

Postby andrewdavey » Tue May 13, 2003 5:41 am

Have you got magic quotes turned on? (personally i hate them)

CrustyDOD
New php-forum User
New php-forum User
Posts: 13
Joined: Tue Oct 29, 2002 2:58 am

Postby CrustyDOD » Tue May 13, 2003 9:12 am

its the same result if magic quotes are ON or if they are OFF, so
any other idea avaible?:)

i'm driving my self crazy with this... HEEEEEEEEEEEEEEEEEEELP

CrustyDOD
New php-forum User
New php-forum User
Posts: 13
Joined: Tue Oct 29, 2002 2:58 am

Postby CrustyDOD » Tue May 13, 2003 9:34 am

I created new forms and here the code for them:

form.php (1st page)
/////////////////////
<html>

<head>
</head>

<body>

<form method="POST" action="preview.php">
<p><input type="text" name="msg" size="20"><input type="submit" value="Submit" name="B1"><input type="reset" value="Reset" name="B2"></p>
</form>

</body>

</html>
//////////////////////

preview.php (2nd page)
//////////////////////
<html>

<head>

</head>

<body>
<?
$msg = $_POST['msg'];
//$msg = addslashes("$_POST[msg]");
echo $msg;
?>
<br>

<form method="POST" action="end.php">
<p><input type="submit" value="Submit" name="B1"><input type="reset" value="Reset" name="B2"></p>
<input type="hidden" name="msg" value="<?=$msg?>">
</form>

</body>

</html>
////////////////////

end.php (3rd page)
/////////////////
<html>

<head>
</head>

<body>
<?
$msg = $_POST['msg'];
//$msg = addslashes("$_POST[msg]");
//or
//$msg = stripslashes("$_POST[msg]");
echo $msg;
?>
</body>

</html>
/////////////

i tried with this form and also it doesn't work!
my magic quotes are OFF.

anyone knows what's wrong?

i think the problem is between preview and end page, cause if i use preview page as an end page it works fine...

who can fix this?:)

User avatar
Redcircle
Moderator
Moderator
Posts: 830
Joined: Tue Jan 21, 2003 10:42 pm
Location: Michigan USA
Contact:

Postby Redcircle » Tue May 20, 2003 1:32 am

have you tried

Code: Select all

'INSERT INTO `base` (`coll`) VALUES ("'.mysql_escape_string($msg).'")'


CrustyDOD
New php-forum User
New php-forum User
Posts: 13
Joined: Tue Oct 29, 2002 2:58 am

Postby CrustyDOD » Tue May 20, 2003 9:43 am

Yes i tried also using mysql_escape_string and the result is the same!

using insert without slashes, the output is: test
using slashes: test \\\\

any other idea?

User avatar
Redcircle
Moderator
Moderator
Posts: 830
Joined: Tue Jan 21, 2003 10:42 pm
Location: Michigan USA
Contact:

Postby Redcircle » Tue May 20, 2003 8:28 pm

do

mysql_escape_string(trim($msg))


Return to “PHP General”

Who is online

Users browsing this forum: Bing [Bot] and 1 guest