Jump to content

Passing Variables


Xtremer360

Recommended Posts

What I'm wanting to do is when the user clicks on Arenas it will know the name of the country it's wanting to see the list of Arenas for but don't know how to pass it. I'm sure it's with a hidden input tag but if this is true where at do I place it and what do I do to option case 3 where it displays the list of arenas at?

 

<?php 
$e = <<<here
    <script src="./jscripts/scriptaculous/prototype.js" type="text/javascript"></script>
	<script src="./jscripts/scriptaculous/scriptaculous.js" type="text/javascript"></script>
	<script type="text/javascript" src="./jscripts/ajax.js"></script>
here;
switch ($_REQUEST['option']) {
	case 0:
		echo $e;
		?>
            <h1 class=backstage>Arena Management</h1><br />
            <h2 class="backstage">Countries :: <a href="#" onclick="ajaxpage('backstage_libs/arenas.php?option=1', 'content'); return false;">Add New</a></h2><br />
            <table width="100%" class="table1">
                <tr class="rowheading">
                    <td> </td>
                    <td width="20" align="center">ID</td>
                    <td>Country</td>
                    <td> </td>
                </tr>
            <?php    
            $query = "SELECT * FROM efed_list_arenas_countries ORDER BY `country`";
            $result = mysql_query ( $query ); 
    
            if ($result) {
			$i = 0;
			while ( $row = mysql_fetch_array ( $result, MYSQL_ASSOC ) ) {
				$sClass = 'row2';
				if ($i++ % 2) $sClass = 'row1';
				printf ( "<tr class=\"%s\">", $sClass );
                    print "<td valign=\"top\" align=\"center\" width=\"30\"><a href=\"#\" onclick=\"ajaxpage('backstage_libs/arenas.php?option=2', 'content'); return false;\">Edit</a></td>";
                    printf ( "<td align=\"center\" width=\"20\">%s</td>", $row [id] );
                    printf ( "<td valign=\"top\">%s</td>", $row [country] );
                    print "<td valign=\"top\" align=\"center\" width=\"80\"><a href=\"#\" onclick=\"ajaxpage('backstage_libs/arenas.php?option=3', 'content'); return false;\">Arenas</a></td>";
                    echo '</tr>';
                }
			echo '</table><br>';
		} else {
			echo '<span>There are no match types.</span><br />';
		}
		returnmain();
	break;
	case 1:
		echo $e;
		require_once('../backstagefunctions.php');
		?>  
            <h1 class="backstage">Arena Management</h1><br />
            <h2 class="backstage">Add Country</h2><br />
            <form name="addcountry" method="post">
			<input type="hidden" name="action" value="arenas" />
                <table width="100%" class="table2">
                    <tr>
                        <td width="120" class="rowheading" valign="center">Country:</td><td class="row3"><input type="text" name="country" class="fieldtext490"></td>
                    </tr>
                </table><br />
                <input type="hidden" name="newadded" value="true">
                <input type="submit" value="Save Country" class=button></form><br />
                <input type="button" value="Return to Country List" class="button200"><br />
            </form><br />
		<?php
		returnmain();
	break;
	case 2:
		echo $e;
		require_once('../backstagefunctions.php');
		?>
            <h1 class="backstage">Arena Management</h1><br />
            <h2 class="backstage">Edit Country</h2><br />
            <table width="100%" class="table2">
                <tr>
                    <td width="120" class="rowheading" valign="center">Country:</td><td class="row3"><input type="text" name="country" class="fieldtext490" value=""></td>
                </tr>
            </table><br />
            <input type="checkbox" name="deletecountry"><span class="table1heading">Delete Country and Arenas?</span><br /><br />
            <input type="submit" value="Edit Country" class=button><br /><br />
            <input type="button" value="Return to Country List" class="button200"><br /><br />
        </form><br />
            <?php
            returnmain();
        break;
	case 3:
		echo $e;
		require_once('../backstagefunctions.php');
		?>
            <h1 class=backstage>Arena Management</h1><br />
            <h2 class=backstage>Arenas :: <a href="#" onclick="ajaxpage('backstage_libs/arenas.php?option=4', 'content'); return false;">Add New</a></h2><br />
            <table width="100%" class="table1">
                <tr class="rowheading">
                    <td> </td>
                    <td>Location</td>
                    <td>Arena</td>
                    <td align=center>Capacity</td>
                </tr>
            <?php
            $query = "SELECT * FROM efed_list_arenas";
            $result = mysql_query ( $query ); 
    
            if ($result) {
			$i = 0;
			while ( $row = mysql_fetch_array ( $result, MYSQL_ASSOC ) ) {
				$sClass = 'row2';
				if ($i++ % 2) $sClass = 'row1';
				printf ( "<tr class=\"%s\">", $sClass );
                    print "<td valign=\"top\" align=\"center\" width=\"30\"><a href=\"#\" onclick=\"ajaxpage('backstage_libs/arenas.php?option=5', 'content'); return false;\">Edit</a></td>";
                    printf ( "<td valign=\"top\">%s</td>", $row [city] );
                    printf ( "<td valign=\"top\">%s</td>", $row [arena] );
                    printf ( "<td align=\"center\" valign=\"top\">%s</td>", $row [capacity] );
                    echo '</tr>';
                }
			echo '</table><br>';
		} else {
			echo '<span>There are no match types.</span><br />';
		}
		returnmain();
	break;
	case 4:
		echo $e;
		require_once('../backstagefunctions.php');
		?>  
            <h1 class="backstage">Arena Management</h1><br />
            <h2 class="backstage">Add New Arena</h2><br />
            <form name="addarena" method="post">
                <table width="100%" class="table2">
                    <tr>
                        <td width="120" class="rowheading" valign="center">Arena:</td><td class="row3"><input type="text" name="name" class="fieldtext490"></td>
                    </tr>
                    <tr>
                        <td width="120" class="rowheading" valign="center">City, State:</td><td class="row3"><input type="text" name="location" class="fieldtext490"></td>
                    </tr>
                    <tr>
                        <td width="120" class="rowheading" valign="center">Capacity:</td><td class="row3"><input type="text" name="capacity" class="fieldtext140"></td>
                    </tr>
                </table><br />
                <input type="hidden" name="newadded" value="true">
                <input type="submit" value="Save Arena" class="button" name="addarena"><br /><br />
                <input type="button" value="Return to Arena List" class="button200"><br /><br />
            </form><br />
		<?php
		returnmain();
	break;
	case 5:
		echo $e;
		require_once('../backstagefunctions.php');
		?>
            <h1 class="backstage">Arena Management</h1><br />
            <h2 class="backstage">Edit Arena</h2><br />
            <form name="editarena" method="post">
                <table width="100%" class="table2">
                    <tr>
                        <td width="120" class="rowheading" valign="center">Arena:</td><td class="row3"><input type="text" name="name" class="fieldtext490"></td>
                    </tr>
                    <tr>
                        <td width="120" class="rowheading" valign="center">City, State:</td><td class="row3"><input type="text" name="location" class="fieldtext490"></td>
                    </tr>
                    <tr>
                        td width="120" class="rowheading" valign="center">Capacity:</td><td class="row3"><input type="text" name="capacity" class="fieldtext140"></td>
                    </tr>
                </table><br />
                <input type="submit" value="Save Arena" class="button" name="addarena"><br /><br />
                <input type="button" value="Return to Arena List" class="button200"><br /><br />
            </form>
		<?php
		returnmain();
	break;
}
function arenas() {
	if ((!empty($_POST['newadded']))) {
		$country = mysql_real_escape_string($_POST['country']);
		$query = "INSERT INTO `efed_list_arenas_countries` (country) VALUES ('".$country."')";
		if (mysql_query($query)) {
			//success
		} else {
			//fail
		}
	}
}
?>

Link to comment
Share on other sites

I know its this line:

 

<a href=\"#\" onclick=\"ajaxpage('backstage_libs/arenas.php?option=3&id=$row['id']', 'content'); return false;\">

 

Its giving me this error message.

 

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/content/y/a/n/yankeefaninkc/html/defiant/backstage/backstage_libs/arenas.php on line 33

Link to comment
Share on other sites

hey,

 

check your invisible characters.  you have a invalid space after your initial php declaration

 

in fact your code has almost a hundred invalid invisible characters.  You probably copied this code offline.  Go through and type it out yourself or get a good text editor to replace them

 

i attached an image. see those circles? those are invisible invalid characters

 

 

 

[attachment deleted by admin]

Link to comment
Share on other sites

hey,

 

check your invisible characters.  you have a invalid space after your initial php declaration

 

in fact your code has almost a hundred invalid invisible characters.  You probably copied this code offline.  Go through and type it out yourself or get a good text editor to replace them

 

i attached an image. see those circles? those are invisible invalid characters

 

Horizontal tabs, CRLF's are NOT invalid characters. Hex shows 20 OA OD OD OD 20, Not anything worth noting. Do you even understand whitespace?

 

OP. You're not escaping your string. Just looks at it and you'll see where you went wrong:

<a href=\"#\" onclick=\"ajaxpage('backstage_libs/arenas.php?option=3&id=$row['id']', 'content'); return false;\">

 

$row[]'s if you couldn't spot it.

 

 

Link to comment
Share on other sites

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.