![]() |
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 |
print "<img src='http://$site_url/avatars/non.gif' width='80' height='80'>";
}else{ print "<img src='$get[avatar]' width='80' height='80'>"; } ?> |
Quote:
|
change the " to \", not to /" and it should work fine
|
Quote:
width=\"80\" would have worked, but he had it as width=/"80" |
oh, didn't notice that at first sight, but you're right of course every in the print " ... "; has to be escaped
|
Quote:
thanks again |
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 ^_^ |
$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; } |
Quote:
Thanks for that I will change it right now |
I fucking LOVE PHP...
Just a shame I still need to learn it... But I LOVE IT :) |
All times are GMT -7. The time now is 07:15 PM. |
Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123