|
-
May 12th, 2007, 08:40 AM
#1
Thread Starter
Frenzied Member
problem capturing value with %
Hi all . i have a javascript that makes get request as shown:
localhost/test.php?cmd=visitorRepCommand¶ms=visitorTyping%201&site=2020202&sessionkey=1abbcad8b561c84f7502793f1953a37f&d=1178974427466
I wrote a php script that checks if value of params is visitorTyping%201 or visitorTyping%200.But problem is that both of my if statments fails to catch those value.could any one tell me what i am doing wrong here. i checked everything i see the values are passed corectly but it seem i am not checkinng those values corectly!!Thanks
PHP Code:
<?
$cmd = $_GET['cmd'];
$params = $_GET['params'];
....
else if ($cmd=="visitorRepCommand" && $params=="visitorTyping%200")
{
echo "test1";
}
else if ($cmd=="visitorRepCommand" && $params=="visitorTyping%201")
{
echo "test2";
}
?>
-
May 12th, 2007, 08:49 AM
#2
Re: problem capturing value with %
%20 is the URL-encoded form of a space character. PHP automatically URL-decodes HTTP parameters, so 'visitorTyping$201' comes out as 'visitorTyping 1'.
-
May 12th, 2007, 09:07 AM
#3
Thread Starter
Frenzied Member
Re: problem capturing value with %
 Originally Posted by penagate
%20 is the URL-encoded form of a space character. PHP automatically URL-decodes HTTP parameters, so 'visitorTyping$201' comes out as 'visitorTyping 1'.
thanks for you reply. Now i tried to do this but my query never writes to db!! could you tell me what might be wrong here?
PHP Code:
else if ($cmd=="visitorRepCommand" && $params=="visitorTyping 0")
{
$server = "localhost"; // MySQL hostname
$username = "root"; // MySQL username
$password = "root"; // MySQL password
$dbname = "db"; // MySQL db name
$db = mysql_connect($server, $username, $password) or die(mysql_error());
mysql_select_db($dbname) or die(mysql_error());
$query = "INSERT INTO userTypingStatus(`ID`, `cmd`, `params`, `site`, `sessionkey`) VALUES ('$ID','$cmd','$params','$site', '$sessionkey')";
$fp = fopen("userTypingStatus.txt", "w");
fwrite($fp, $query);
fclose($fp);
$result = mysql_query( $query );
echo "test1";
}
my log file shows this but when i check db nothing is there!!
INSERT INTO userTypingStatus(`ID`, `cmd`, `params`, `site`, `sessionkey`) VALUES ('','visitorRepCommand','visitorTyping 0','7878765', '1abbcad8b561c84f7502793f1953a37f')
-
May 14th, 2007, 04:02 PM
#4
Re: problem capturing value with %
add some error checking for the mysql_query() call.
PHP Code:
mysql_query($query) or die('error: ' . mysql_error());
see what the problem is. mistyped field name, bad field type or size? strict sql mode on, maybe?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|