Jump to content

How can i put php code in a variable


corrupshun

Recommended Posts

How can i store all of this in varible $gamecode

(idk how to put php code in variables)

$nothing = "";
$list = range(1,2);
if(!isset($_GET['gameid'])) {
include("inc/defaultgame.php");
}
elseif($_GET['gameid'] == $nothing){
include("inc/defaultgame.php");
}
elseif(in_array($_GET['gameid'], $list) === false) {
echo('Invalid GameID');
}
else {
$con = mysql_connect("localhost","root","");
mysql_select_db("Corrupshun", $con);
$query = mysql_query("SELECT Title, Path FROM Games WHERE id = $_GET[gameid]");
while($row = mysql_fetch_assoc($query)) {
$gamepath = $row['Path'];
$gametitle = $row['Title'];
}
}

This is probably a really dumb question

Link to comment
https://forums.phpfreaks.com/topic/183365-how-can-i-put-php-code-in-a-variable/
Share on other sites

what ever type of quote you surround any string with (" or ') you need to escape any occurrences of that character inside the string with the escape character (\) for example this is good

$string = "he said \"hey\" to me!";
//more code

bad

$string = 'my name is o'neil';
//more code

 

notice the difference in syntax highlighting.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.