Jump to content

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.