Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Post New Thread Reply

Register GFY Rules Calendar Mark Forums Read
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed.

 
Thread Tools
Old 09-14-2008, 03:54 AM   #1
halfpint
GFY's Halfpint
 
halfpint's Avatar
 
Industry Role:
Join Date: Jun 2007
Location: UK
Posts: 15,223
Php Help Please

I keep getting parsing errors on this script on line 20. I was told it is because the quotes are not being escaped.. so when you have a " or a ' you need to escape the quote with a / but not the first and end quotes..something like that I think. I cant figure it out

can anybody help please

Code:
        <div align=left><?php 

$getinfo = mysql_query("SELECT username,email,gameplays,avatar,comments,location,gender,favgame,joined,im,status,id FROM users WHERE username='$_REQUEST[user]'") or die(mysql_error());
$get = @mysql_fetch_array($getinfo);
if(@mysql_num_rows($getinfo) == '0') {
?> 
<h1>No User To View Profile</h1> 
<br> 
<br> 
<?php
}else{
?> 
<?php echo"$top_games";?> <?php echo"$latest_games";?> <?php echo"$affiliates";?> <br> 
<h1> 
  <?=$_REQUEST[user]?> 
  's Profile</h1> 
<br> 
<br>
 <?php if($get[avatar] == '') {
  print "<img src=http://$site_url/avatars/non.gif width=/"80" height=/"80">";
}else{ print "<img src=$get[avatar] width=/"80" height=/"80">"; } ?> 
<br> 
<br> 
<strong> 
<?php if($get[status] == '0') {
  print "<font color=red>I am currently offline</font>";
}elseif($get[status] == '1'){
  print "<font color=green>I am currently online</font>";
}
?> 
</strong><br> 
<strong>Total Video Plays:</strong> 
</h3> 
<?=$get[gameplays]?> 
<br> 
<br> 
<strong>Location:</strong> 
</h3> 
<?=$get[location]?> 
<br> 
<br> 
<strong>IM:</strong> 
</h3> 
<?=$get[im]?> 
<br> 
<br> 
<strong>Gender:</strong> 
</h3> 
<?=$get[gender]?> 
<br> 
<br> 
<strong>Favorite Game:</strong> 
</h3> 
<?=$get[favgame]?> 
<br> 
<br> 
<strong>Date Joined:</strong> 
<?=$get[joined]?> 
<br> 
<br> 
<strong>Comments:</strong> <?php 
$comments = stripslashes($get[comments]);
print wordwrap($comments); ?><br> 
<br> 
<a href="page.php?page=pms&compose=1&to=<?=$_REQUEST[user]?>">Send this user a PM</a><br> 
<br> 
<br> 
<br> 
<center> 
 <?php if ($adult ==1 || $porn_setting==1){ include("cache/ad-1-468x60.php"); } else{ include("cache/ad-0-468x60.php"); } ?> 
</center> 
<?php 

$query4 = "SELECT gid,gname FROM favoritegames WHERE uid='$_REQUEST[user]'";
$result4 = mysql_query($query4) or die(mysql_error());

if(@mysql_num_rows($result4) == '0') {
}else{
?> 
<h1>My Favorite Games:</h1> 
<?php 
while (list ($id, $name) = mysql_fetch_row($result4)) {

echo "<br><a href=./play.php?action=play&id=$id>$name</a>";

} } ?> 
<?php } ?> <br><br><br><br><br><br><br><br><br><br>
</div>
__________________

Get FREE website listings on Cryptocoinshops.net
halfpint is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-14-2008, 03:55 AM   #2
k0nr4d
Confirmed User
 
k0nr4d's Avatar
 
Industry Role:
Join Date: Aug 2006
Location: Poland
Posts: 9,229
print "<img src='http://$site_url/avatars/non.gif' width='80' height='80'>";
}else{ print "<img src='$get[avatar]' width='80' height='80'>"; } ?>
k0nr4d is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-14-2008, 03:58 AM   #3
halfpint
GFY's Halfpint
 
halfpint's Avatar
 
Industry Role:
Join Date: Jun 2007
Location: UK
Posts: 15,223
Quote:
Originally Posted by k0nr4d View Post
print "<img src='http://$site_url/avatars/non.gif' width='80' height='80'>";
}else{ print "<img src='$get[avatar]' width='80' height='80'>"; } ?>
thank you
__________________

Get FREE website listings on Cryptocoinshops.net
halfpint is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-14-2008, 03:59 AM   #4
StariaDaniel
Confirmed User
 
Join Date: Oct 2007
Location: Netherlands
Posts: 415
change the " to \", not to /" and it should work fine
StariaDaniel is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-14-2008, 04:01 AM   #5
k0nr4d
Confirmed User
 
k0nr4d's Avatar
 
Industry Role:
Join Date: Aug 2006
Location: Poland
Posts: 9,229
Quote:
Originally Posted by StariaDaniel View Post
change the " to \", not to /" and it should work fine
that wouldn't have worked, because he was only escaping 1 of the " not the second one
width=\"80\" would have worked, but he had it as width=/"80"
k0nr4d is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-14-2008, 04:02 AM   #6
StariaDaniel
Confirmed User
 
Join Date: Oct 2007
Location: Netherlands
Posts: 415
oh, didn't notice that at first sight, but you're right of course every in the print " ... "; has to be escaped
StariaDaniel is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-14-2008, 04:03 AM   #7
halfpint
GFY's Halfpint
 
halfpint's Avatar
 
Industry Role:
Join Date: Jun 2007
Location: UK
Posts: 15,223
Quote:
Originally Posted by k0nr4d View Post
print "<img src='http://$site_url/avatars/non.gif' width='80' height='80'>";
}else{ print "<img src='$get[avatar]' width='80' height='80'>"; } ?>
used this peice of code and it work ..thanks I love you, this has been driving me mad

thanks again
__________________

Get FREE website listings on Cryptocoinshops.net
halfpint is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-14-2008, 06:35 AM   #8
calmlikeabomb
Confirmed User
 
calmlikeabomb's Avatar
 
Join Date: May 2004
Location: SW Palm Bay, Florida
Posts: 1,323
Why the inconsistency between the use of echo and print?

It's not going to affect your script's performance, but just so you know echo is marginally faster, because it doesn't return a value ^_^
__________________
subarus.
calmlikeabomb is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-14-2008, 11:24 AM   #9
Janh
Confirmed User
 
Janh's Avatar
 
Join Date: Sep 2006
Location: NL
Posts: 332
$query4 = "SELECT gid,gname FROM favoritegames WHERE uid='$_REQUEST[user]'";


This is bad.. everyone can hack your database with query injection.

Solve this with one off the folowing examples.

1: (If uid is numeric)
$query4 = "SELECT gid,gname FROM favoritegames WHERE uid=".(int)$_REQUEST[user];

2: (if uid is an text/varchar)
$query4 = "SELECT gid,gname FROM favoritegames WHERE uid='".mysql_real_escape_string($_REQUEST[user]).'";

Its always better to do this via an public checkfunction as below

$query4 = "SELECT gid,gname FROM favoritegames WHERE uid=".dbcheck($_REQUEST[user]);



function dbcheck($dbValue,$dbType="s"){
$dbTemp = $dbValue;
$dbTemp = str_Replace("'","''",$dbTemp);

$dbTemp = stripslashes($dbTemp);
$dbTemp = str_Replace("\\","\\\\",$dbTemp);
switch(strtolower($dbType)){
case "i":
// Numbers
if (is_Numeric($dbTemp)){
$check = $dbTemp;
} else {
$check = "0";
}
break;
case "b":
// Boolean
if ( $dbTemp>0 ){
$check = 1;
} else {
$check = 0;
}
break;
default:
// String
//if (strlen($dbTemp)>0) {
$check = "'" . $dbTemp . "'";
//} else {
//$check = "Null";
//}
break;
}
return $check;
}
__________________
Contact me for buy/sell traffic or visit www.ero-advertising.com

Advertise with Text ads, Thumb ads, Banners, Video ads, Layer ads or AdSpaces (fixed spots at fixed prices). All traffic is GEO-IP & country filtered (and anti-fraud checked).

Last edited by Janh; 09-14-2008 at 11:28 AM.. Reason: Update
Janh is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-14-2008, 12:12 PM   #10
halfpint
GFY's Halfpint
 
halfpint's Avatar
 
Industry Role:
Join Date: Jun 2007
Location: UK
Posts: 15,223
Quote:
Originally Posted by Janh View Post
$query4 = "SELECT gid,gname FROM favoritegames WHERE uid='$_REQUEST[user]'";


This is bad.. everyone can hack your database with query injection.

Solve this with one off the folowing examples.

1: (If uid is numeric)
$query4 = "SELECT gid,gname FROM favoritegames WHERE uid=".(int)$_REQUEST[user];

2: (if uid is an text/varchar)
$query4 = "SELECT gid,gname FROM favoritegames WHERE uid='".mysql_real_escape_string($_REQUEST[user]).'";

Its always better to do this via an public checkfunction as below

$query4 = "SELECT gid,gname FROM favoritegames WHERE uid=".dbcheck($_REQUEST[user]);



function dbcheck($dbValue,$dbType="s"){
$dbTemp = $dbValue;
$dbTemp = str_Replace("'","''",$dbTemp);

$dbTemp = stripslashes($dbTemp);
$dbTemp = str_Replace("\\","\\\\",$dbTemp);
switch(strtolower($dbType)){
case "i":
// Numbers
if (is_Numeric($dbTemp)){
$check = $dbTemp;
} else {
$check = "0";
}
break;
case "b":
// Boolean
if ( $dbTemp>0 ){
$check = 1;
} else {
$check = 0;
}
break;
default:
// String
//if (strlen($dbTemp)>0) {
$check = "'" . $dbTemp . "'";
//} else {
//$check = "Null";
//}
break;
}
return $check;
}

Thanks for that I will change it right now
__________________

Get FREE website listings on Cryptocoinshops.net
halfpint is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-14-2008, 12:12 PM   #11
CurrentlySober
Too lazy to wipe my ass
 
CurrentlySober's Avatar
 
Industry Role:
Join Date: Aug 2002
Location: A Public Bathroom
Posts: 38,644
I fucking LOVE PHP...

Just a shame I still need to learn it... But I LOVE IT
__________________


👁️ 👍️ 💩
CurrentlySober is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Post New Thread Reply
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >

Bookmarks
Thread Tools



Advertising inquiries - marketing at gfy dot com

Contact Admin - Advertise - GFY Rules - Top

©2000-, AI Media Network Inc



Powered by vBulletin
Copyright © 2000- Jelsoft Enterprises Limited.