Jump to content

function within an for loop


tyrisia

Recommended Posts

Hi All, I'm having a bit of trouble with a session script, basically there is a function within a for loop that protects the target of the link it produces. Instead of creating the link it produces something a bit like:

 

&entries=/linksout.php?PHPSESSID=b7ed5961a8bce563faa7a1307d04ff82&sitelokaction=getfiled&sitelokfile=night.swf&auth=90af7e3077a5d19fcce57d6785aef52f/night.swfloop series track 1&

 

Here's the code:

 

$DBConn = mysql_connect($DBhost,$DBuser,$DBpass) or die("Error in GuestBook Application: " . mysql_error());
   // Select mySQL Database
   mysql_select_db($DBName, $DBConn) or die("Error in GuestBook Application: " . mysql_error());

$sql = "SELECT * FROM $table WHERE Username LIKE '%$user%' ORDER BY date";
$alltracks = mysql_query($sql, $DBConn) or die("Error in GuestBook Application: " . mysql_error());
$numalltracks = mysql_num_rows($alltracks);
print '<br>&entries=';	

	 if($numalltracks == 0) {
	    print "No tracks purchased yet";
	 } else { 
	    for ($i=0; $i<$numalltracks; $i++) {
		$name = mysql_result($alltracks, $i, 'title');

		   $link = mysql_result($alltracks, $i, 'link');
		   $date = mysql_result($alltracks, $i, 'date');
		   

		  // echo '<a href=\"' . siteloklink($link,1) . '\">' . $name . '</a>';
		   print '<a href="' . (siteloklink($link,1)) . '">' . $name . '</a>';
	   }
	}print "&";

 

Hope someone can help here, it's got me baffled..

Link to comment
Share on other sites

Ok, what I want to know is how do I get my function (siteloklink($link,1)) to produce the relevant hyperlink for each row of the array outputted from the database, instead of printing (or echoing) the function's result in whole, but not allowing me to link to the file defined in the function?

Link to comment
Share on other sites

that line of code produces the following:

 

&entries=/linksout.php?PHPSESSID=4cdb784562751c9ea1a522a61bdd5434&sitelokaction=getfiled&sitelokfile=night.swf&auth=0f0177eaba5a7cd7c57786b6418620b7/night.swfloop series track 1[/url]&

Link to comment
Share on other sites

Here it is:

 

function siteloklink($fname,$dialog)

{

  global $thispage,$SiteKey,$NoExtraPath;

  // See if location specified

  $auth=md5(session_id().$fname.$SiteKey);

  $link=$thispage."?PHPSESSID=".session_id()."&sitelokaction=";

  if ($dialog==0)

    $link.="getfile";

  else

    $link.="getfiled";

  $link.="&sitelokfile=".$fname;

  $link.="&auth=".$auth;

  $fname=strtok($fname,":");

if ($NoFilename!=1)

  $link.="/".$fname;

  print($link);

}

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.