Page 1 of 1

Sending definitive info through a link

Posted: Mon Jul 16, 2007 3:25 pm
by beloveddoll
I have links set up as thus:
explore7.php?id=7&p=4

Where when the link is clicked on, id will always be 7 and p will always be 4. id is being sent fine but p isn`t. How can I get p sent?

Posted: Mon Jul 16, 2007 3:29 pm
by Ambush Commander
Are you html entity-izing your ampersands?

Posted: Mon Jul 16, 2007 3:32 pm
by beloveddoll
Well, here`s the entire code:

Code: Select all

<?

$option = "link";

$sites[0] = array("javascript:location.reload()", "</a>You found nothing.<p><a href='javascript:location.reload()'>Keep Searching</a>", 10);
$sites[1] = array("explore7.php?id=1&p=4", "</a>You Found a Dark Blue Shell! Click the image to add it to your inventory.<br><a href='explore7.php?id=1'><img src='collection/darkblueshell.png' border=0></a><p><a href='javascript:location.reload()'>Keep Exploring.</a>", 4);
$sites[2] = array("explore7.php?id=2&p=1", "</a>You Found a Light Blue Shell! Click the image to add it to your inventory.<br><a href='explore7.php?id=2'><img src='collection/lightblueshell.png' border=0></a><p><a href='javascript:location.reload()'>Keep Exploring.</a>", 9);
$sites[3] = array("explore7.php?id=4&p=1", "</a>You Found a Light Purple Shell! Click the image to add it to your inventory.<br><a href='explore7.php?id=4'><img src='collection/lightpurpleshell.png' border=0></a><p><a href='javascript:location.reload()'>Keep Exploring.</a>", ;
$sites[4] = array("explore7.php?id=3&p=4", "</a>You Found a Dark Purple Shell! Click the image to add it to your inventory.<br><a href='explore7.php?id=3'><img src='collection/darkpurpleshell.png' border=0></a><p><a href='javascript:location.reload()'>Keep Exploring.</a>", 4);
$sites[5] = array("explore7.php?id=5&p=5", "</a>You Found a Dark Red Shell! Click the image to add it to your inventory.<br><a href='explore7.php?id=5'><img src='collection/darkredshell.png' border=0></a><p><a href='javascript:location.reload()'>Keep Exploring.</a>", 3);
$sites[6] = array("explore7.php?id=6&p=2", "</a>You Found a Light Red Shell! Click the image to add it to your inventory.<br><a href='explore7.php?id=6'><img src='collection/lightredshell.png' border=0></a><p><a href='javascript:location.reload()'>Keep Exploring.</a>", 7);
$sites[7] = array("javascript:location.reload()", "</a>You found nothing.<p><a href='javascript:location.reload()'>Keep Searching</a>", 10);
$sites[8] = array("javascript:location.reload()", "</a>You found nothing.<p><a href='javascript:location.reload()'>Keep Searching</a>", 10);
$sites[9] = array("javascript:location.reload()", "</a>You found nothing.<p><a href='javascript:location.reload()'>Keep Searching</a>", 10);
$sites[10] = array("javascript:location.reload()", "</a>You found nothing.<p><a href='javascript:location.reload()'>Keep Searching</a>", 10);
$sites[11] = array("explore7.php?id=7&p=4", "</a>You Found a Dark Green Shell! Click the image to add it to your inventory.<br><a href='explore7.php?id=7'><img src='collection/darkgreenshell.png' border=0></a><p><a href='javascript:location.reload()'>Keep Exploring.</a>", 4);
$sites[12] = array("explore7.php?id=8&p=2", "</a>You Found a Light Green Shell! Click the image to add it to your inventory.<br><a href='explore7.php?id=8'><img src='collection/lightgreenshell.png' border=0></a><p><a href='javascript:location.reload()'>Keep Exploring.</a>", ;
$sites[13] = array("javascript:location.reload()", "</a>You found nothing.<p><a href='javascript:location.reload()'>Keep Searching</a>", 10);
$sites[14] = array("explore7.php?id=9&p=6", "</a>You Found a Black Shell! Click the image to add it to your inventory.<br><a href='explore7.php?id=9'><img src='collection/blackshell.png' border=0></a><p><a href='javascript:location.reload()'>Keep Exploring.</a>", 3);
$sites[15] = array("javascript:location.reload()", "</a>You found nothing.<p><a href='javascript:location.reload()'>Keep Searching</a>", 10);
$sites[16] = array("javascript:location.reload()", "</a>You found nothing.<p><a href='javascript:location.reload()'>Keep Searching</a>", 10);
$sites[17] = array("javascript:location.reload()", "</a>You found nothing.<p><a href='javascript:location.reload()'>Keep Searching</a>", 10);
$sites[18] = array("explore7.php?id=10&p=10", "</a>You Found a Gold Shell! Click the image to add it to your inventory.<br><a href='explore7.php?id=10'><img src='collection/goldshell.png' border=0></a><p><a href='javascript:location.reload()'>Keep Exploring.</a>", 1);
$sites[19] = array("explore7.php?id=11&p=10", "</a>You Found a Silver Shell! Click the image to add it to your inventory.<br><a href='explore7.php?id=11'><img src='collection/silvershell.png' border=0></a><p><a href='javascript:location.reload()'>Keep Exploring.</a>", 1);
$sites[20] = array("explore7.php?id=2&p=1", "</a>You Found a Light Blue Shell! Click the image to add it to your inventory.<br><a href='explore7.php?id=2'><img src='collection/lightblueshell.png' border=0></a><p><a href='javascript:location.reload()'>Keep Exploring.</a>", 9);
$sites[21] = array("explore7.php?id=4&p=1", "</a>You Found a Light Purple Shell! Click the image to add it to your inventory.<br><a href='explore7.php?id=4'><img src='collection/lightpurpleshell.png' border=0></a><p><a href='javascript:location.reload()'>Keep Exploring.</a>", ;
$sites[22] = array("explore7.php?id=6&p=2", "</a>You Found a Light Red Shell! Click the image to add it to your inventory.<br><a href='explore7.php?id=6'><img src='collection/lightredshell.png' border=0></a><p><a href='javascript:location.reload()'>Keep Exploring.</a>", 7);
$sites[23] = array("explore7.php?id=8&p=2", "</a>You Found a Light Green Shell! Click the image to add it to your inventory.<br><a href='explore7.php?id=8'><img src='collection/lightgreenshell.png' border=0></a><p><a href='javascript:location.reload()'>Keep Exploring.</a>", ;
$sites[24] = array("javascript:location.reload()", "</a>You found nothing.<p><a href='javascript:location.reload()'>Keep Searching</a>", 10);
$sites[25] = array("javascript:location.reload()", "</a>You found nothing.<p><a href='javascript:location.reload()'>Keep Searching</a>", 10);
$countsites = count($sites);

for($i=0; $i<$countsites; $i++)
	{
	for($x=0; $x<$sites[$i][2]; $x++)
		{
		if($option != null)
			{
			$mylist[] = array($sites[$i][0],$sites[$i][1],$sites[$i][3]);
			}
		else
			{
			echo("Error deciding option.");
			exit();
			}
		}
	}

$countlist = count($mylist);

$countlist = $countlist - 1;

$picker = rand(0, $countlist);

if($option == "link")
	{
	echo("<a href='" . $mylist[$picker][0] . "'>" . $mylist[$picker][1] . "</a>");
	}

else if($option == "banner")
	{
	echo("<a href='" . $mylist[$picker][0] . "'><img alt='" . $mylist[$picker][1] . "' src='" . $mylist[$picker][2] . "' /></a>");
	}

else
	{
	echo("Error deciding option.");
	exit();
	}
?>

Here is explore7.php:

Code: Select all

<?
include("dbcon.php");
include("func.php");
require_once "auth.php";
require_once "includes/defines.php";

$log = $_SESSION['sess_name'];

mysql_query("INSERT INTO coll_inven (user,item,price) VALUES ( '$log', '$id', '$p' )");

   
header("Location: ex_thereefs.php");

?>

Posted: Mon Jul 16, 2007 4:49 pm
by beloveddoll
Solution was found. I didn`t put the &p= to all the link fields.

Posted: Mon Jul 16, 2007 10:58 pm
by feyd
It's highly advised to discontinue using short tags e.g. "<?" in favor of "<?php"

Why? Because it's a bit presumptuous to assume short tags is on, when it's optional in all current stable installs of PHP. In coming versions of PHP it won't even be an option; it will always be off. Using the long form increases the compatibility of your scripts to run on more installs of PHP without need for modification.