Jump to content

[SOLVED] where did my $_GET[id]; go? :)


RyanSF07

Recommended Posts

Hi Guys,

 

I'm trying to figure this out and thought I'd post the bare bones here to see if a second pair of eyes might see the fix faster:

 

I setting an using $_GET[id] in two parts of the page/code, but the in last instance it fails to display. I've trimmed the code to highlight where the problem occurs.

 

I use more or less this same code on pages where the SQL query doesn't not include ORDER BY RANDOM and it works without trouble. Is ORDER By Random causing the problem?

 

<?php
session_start(); 

$sql = "SELECT * FROM video, registered_users WHERE video.user_id = registered_users.id ORDER BY RAND() LIMIT 1";

$query_result = mysql_query($sql);
$row = mysql_fetch_array($query_result);
$_SESSION[get] = $row[id];
$row[id] = $_GET[id];
$video_body = nl2br($row[video]);

$quizvideo = <<<EOD
$video_body
EOD;

$quizcontent .= <<<EOD
<p><b>$row[title]</p></b>
<p>$row[description_text]   </p>

$quizvideo

<iframe src="show_questions.php?id=$_GET[id]" ... (NOTE: $_GET[id]; works here)
EOD;

$embedquiz .= "
add this quiz to your website<br>
<br>
<iframe src="http://www.site.com/view_quiz_inframe.php?id=$_GET[id]..... (NOTE: $_GET[id]; DOES NOT WORK HERE -- ....</iframe> 

......
?>

 

Link to comment
https://forums.phpfreaks.com/topic/172856-solved-where-did-my-_getid-go/
Share on other sites

Your code is all the way pretty terrible. And you should use single quotes around the indexses in arrays $_GET[id] --> $_GET['id']. In the second time you TRY to use $_GET['id'] it is not parsed by php at all. It is just part of the string $embedquiz. And also you are not ending that string with quotation mark & semicolon which should lead in to error. If you want to use php variable inside string you could do:

 

<?php
$someString = 'Testing diipa daapa and id is : ' . $_GET['id'] . ' and the string continues..';

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.