Jump to content

What does this mean or does..


2old2learn?

Recommended Posts

Hey; Some time ago a friend created " A game recording(track)file management system for a ladder site...he started the script like this..

<?php$index%loaded=1;

I am not at this time posting the whole script he did because while I printed it oun on a printer it printed 8 pages..he did some heavy duty scripting for us...whew...thank god ..he knew what he was doing..at times I read thru it hoping I can pick up some pointers from it...LOLthanks..

Link to comment
Share on other sites

That's not a valid line. The % character is not allowed in variable names, it is the modulus operator. Any operator expression does not go on the left side of an assignment statement, only the right side. That line would be a syntax error. You can use a tool like this to check:http://tools.sopili.net/php-syntax-check/

Link to comment
Share on other sites

That's not a valid line. The % character is not allowed in variable names, it is the modulus operator. Any operator expression does not go on the left side of an assignment statement, only the right side. That line would be a syntax error. You can use a tool like this to check:http://tools.sopili.net/php-syntax-check/
I just typed in this
 $index%loaded=1;

and it gave " No syntax errors detected in code"

Link to comment
Share on other sites

I just typed in this
 $index%loaded=1;

and it gave " No syntax errors detected in code"

It gives an error if you check the box that says "Plus <?php...?>" (Which seems kind of counter intuitive if you ask me....)You also get an error if you try to run a PHP file with that code in it.
Link to comment
Share on other sites

If the actual line looks something like this: if ($index % loaded == 1) andloaded is a constant defined somewhere else in the script, it could do something.I can't help thinking you've left out something important.

Link to comment
Share on other sites

I just typed in this
$index%loaded=1;

and it gave " No syntax errors detected in code"

That's because that's not PHP code. This is PHP code:
<?php$index%loaded=1;?>

That checker uses built-in PHP functions to check the syntax, so it expects a regular PHP document. Without the PHP tags, it's not PHP code. The checkbox on the page automatically wraps whatever you type with PHP code.

Link to comment
Share on other sites

That's because that's not PHP code. This is PHP code:
<?php$index%loaded=1;?>

That checker uses built-in PHP functions to check the syntax, so it expects a regular PHP document. Without the PHP tags, it's not PHP code. The checkbox on the page automatically wraps whatever you type with PHP code.

LOL duh?...I fogot the <?php...It gave this..." Parse error: syntax error, unexpected '=' in CODE on line 3 Errors parsing CODE "
Link to comment
Share on other sites

If the actual line looks something like this: if ($index % loaded == 1) andloaded is a constant defined somewhere else in the script, it could do something.I can't help thinking you've left out something important.
Oh yea I did leave something out...8 pages of code..so it very well do something else in the script somewhere..I can send you this if you like to look it over..???
Link to comment
Share on other sites

Oh yea I did leave something out...8 pages of code..so it very well do something else in the script somewhere..I can send you this if you like to look it over..???
What is the line trying to do? Assign or compare?
Link to comment
Share on other sites

What is the line trying to do? Assign or compare?
I have no idea what its trying to do or what it is suppose to do..like I said in my first post..this is not mine...its a friend who I no longer am in contact with..he made the script for My ladder competition site..and that is the second line in hes script page..which is 8 pages long....just curious if anyone had an idea..I did manage to get it to work and display the uploaded files..but to download these files got an error...8 page script
Link to comment
Share on other sites

If may be helpful for you to give us the first 5 lines or something, so we can see that code in context. Give us everything exactly as it is for the first 5 lines or so.

Link to comment
Share on other sites

If that is line two, bet anything line one is an include file, so a lot of other code is executing first. That or this is in an include file and depends on a lot of other code executing first.Either way, that = sign cannot be correct. Or the % is not correct. Could also be a $ is missing before loaded.

Link to comment
Share on other sites

If that is line two, bet anything line one is an include file, so a lot of other code is executing first. That or this is an include file and depends on a lot of other code executing first.Either way, that = sign cannot be correct. Or the % is not correct. No way around that.
I agree one of the two is not right. I'm hoping that by getting a wider scope, we'll be able to see a more accurate representation of the code. My theory is that he just typed it straight in here himself, and I'd rather see him copy and paste a set of lines, so we'll see it all in it's actual form.
Link to comment
Share on other sites

I agree one of the two is not right. I'm hoping that by getting a wider scope, we'll be able to see a more accurate representation of the code. My theory is that he just typed it straight in here himself, and I'd rather see him copy and paste a set of lines, so we'll see it all in it's actual form.
I did just typed it in here from the script file wanting to know what it meant...and what purpose it did...LOL I am at work right now..when I get home tonight I will post some of the first page..for you..but the first two lines are
<?php$index%loaded=1;//comments//and a couple of include files..

if I remember correctly thats what it shows..... will post some of the code later tonight ...again remember the whole script my friend did is 8 pages long...its massive...cheers..

Link to comment
Share on other sites

We'll just need the first bit. Copy and paste it straight in if you can.By the way, the size of the script doesn't matter. I can make one page into 8 if I changed things like this:

$one = 4;$two = 6;$sum = $one + $two

into

/* * A class designed to add two numbers */class Adder{  /*   * The two numbers that get added   */  private $one;  private $two;  /*   * Instantiate an Adder with two numbers to be added   */  public function __construct($one, $two)  {	$this->one = $one;	$this->two = $two;  }  /**   * Returns the sum of the two numbers   */  public function getSum()  {	return $this->one + $this->two;  }}$adder = new Adder(4, 6);$sum = $adder->getSum();

That particular example may seem redundant, but the point is that more code doesn't necessarily mean anything. You seem to be constantly reminding us that it is 8 pages, but we're not going to pay any attention to that, because it's doesn't make it impressive, nor does it even pertain to your question.Sorry if I seem nit picky, it just bugs me when people point out a simple detail over and over while others have not brought any attention to it, hinting that it doesn't really matter.

Link to comment
Share on other sites

wow, easy man. I don't think he's trying to impress anyone, as he's clearly stated it's not his code. All he's asking is for an explanation of a line, and trying to provide context to us to provide as much detail up front. To you it might seem like 8 pages is inconsequential, to someone who is a beginner at coding and would have a harder time recognizing what is or isn't important, 8 pages might as well be a book. Given how object oriented PHP has become, and without seeing the full page in question in action, who knows if there are includes at the top of the page. Maybe the code snippet in question comes later on in the page, and is just provided missing an important symbol or operator. Also, DD has already pointed out that includes could well be a part of the overall picture. I would beg to differ that that wouldn't matter. Just sayin...

Link to comment
Share on other sites

I'm not saying the code is unimportant, I'm just saying that we don't need reminded of it's size.Again, sorry for being nit picky, I just wanted to explain to him that he doesn't need to keep saying it. We, being the attentive crew we are, read it the first time =P Hopefully that clears it up.Anyway, I understand that the rest of the code could impact this line, that's why I'm pressing for some context.

Link to comment
Share on other sites

Thank you for your patience..I am home now..How to follow is maybe at least 20 or 30 so line of code starting with the $index%loaded=1;..This script was written for this reason.." A game recording(track)file management system..

<?php$indexloaded = 1;/** * A game recording (track) file management system  * *  * @copyright Copyright (c) 2008, Team Combat League */include('config/config.php');include("$dir[func]/global.php");include("$dir[func]/loginforms.php");define('STORAGE_DIR', '/home/teamcomb/public_html/mgl/tracks');$content = '';$action = $_REQUEST['action'];if ($action == 'upload_complete' && $_POST['upload_files'] != '') {	if ($plyr[id] != 0) {		$result = complete_file_upload($plyr[id]);		if ($result != 'SUCCESS!') {			$content .= $result;		} else {			$content .= 'File upload successful. <a href="mgl/tracks.php">Continue</a>';		}	} else {		die ('Permissions error. You must log in.');	}} else if ($action == 'delete_file' && $_GET['delete'] != '') {	if ($admn[id] != 0) {		$result = delete_file_id($_GET['delete']);		if ($result != 'SUCCESS!') {			$content .= $result . '<br>';		} else {			$content .= 'File deleted<br>';		}		$content .= '<a href="/mgl/tracks.php?action=admin_panel">Okay</a>';	} else {		die ('Permssions error. You must log in as an admin.');	}	} else if ($action == 'upload_start' && $plyr[id] != 0) {	$content .= get_upload_form_html($plyr[id], $_GET['matchid']);} else if ($action == 'admin_panel' && $admn[id] != 0) {	$content .= get_all_tracks_table_admin();	$content .= '<a href="mgl/tracks.php">Tracks Home</a>';} else if ($action == 'viewmatch' && $_GET['matchid'] != '') {	$matchid = mysql_real_escape_string(stripslashes($_GET['matchid']));	$content .= get_match_tracks_table($matchid);	if (is_upload_allowed_match($plyr[id], $matchid)) {		$content .= "<br><form action='/mgl/tracks.php' method='GET'>		<input type='hidden' name='action' value='upload_start'>		<input type='hidden' name='matchid' value='$matchid'>		<input type='submit' value='Add a Track'>		</form>";	}

Again this is only a small portion of the script...that my friend had done for us..I just was curious about the line " $index%loaded=1; " Thank you...

Link to comment
Share on other sites

$indexloaded = 1;That's the second line. There's no % in it.
LOL...sorry for miss reading it.....old man you know..my bad..anyways what is the purpose of it..and what does it do...My best guess it means if index page is true. ...then do this..but this is a guess..I am trying to grasp the concept of all this...
Link to comment
Share on other sites

LOL...sorry for miss reading it.....old man you know..my bad..anyways what is the purpose of it..and what does it do...My best guess it means if index page is true. ...then do this..but this is a guess..I am trying to grasp the concept of all this...
My guess is that your guess is pretty close... :)I'm thinking it's most likely used in the included files to make sure that none of the code in those files is executed unless the index page has been loaded first (ie, somebody typed www.sitename.com/config/config.php in the browser). Depending on what's in those files, you probably wouldn't want to run the config file or define a bunch of globals outside of the context of the index page.
Link to comment
Share on other sites

$indexloaded = 1;That's the second line. There's no % in it.
Sorry, if you look at my first post it has always shown it was the second line never said different....
Link to comment
Share on other sites

My guess is that your guess is pretty close... :)I'm thinking it's most likely used in the included files to make sure that none of the code in those files is executed unless the index page has been loaded first.
Hey thanks for the encouragement...it always helps a newcomer to move forward..thanks again..
Link to comment
Share on other sites

My guess is that your guess is pretty close... :)I'm thinking it's most likely used in the included files to make sure that none of the code in those files is executed unless the index page has been loaded first (ie, somebody typed www.sitename.com/config/config.php in the browser). Depending on what's in those files, you probably wouldn't want to run the config file or define a bunch of globals outside of the context of the index page.
ahhh makes sense...thanks
Link to comment
Share on other sites

its looks like its only initializing the variable. as there is no $indexloaded variable i can see is in your code fraction so its hard to tell why has been used it. it may be used later on this code page or may be can used in the included files. if you try to find the relative part where that variable being used, could be easier to determine the purpose of it.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...