Jump to content

[SOLVED] no idea what to do...


The14thGOD

Recommended Posts

I'm fed up. I had issues with code that I have working on a different site that didn't work on my current site. I found a way to fix that but now I'm running into the same error on another page that I can't think of a way around:

 

'Parse error: syntax error, unexpected T_VARIABLE, expecting ']' in /my/path/to/file on line 75'

Here's the original code: (ine 75 is the line with the link in it.)

<?php
        			$adquery = "SELECT * FROM ad_space WHERE id=1";
        			$adresult = mysql_query($adquery);
        			$adrow = mysql_fetch_assoc($adresult);
        			for($i=1;$i<6;$i++){
        				if($row['link'.$i] == '') {
        					$row['link'.$i] = '#';
        				}
        				echo "<a href=\"$row[link$i]\" target=\"_blank\"><img src=\"$row[image$i]\" alt=\"$i\" /></a>";
        			}
        		?>

 

I changed it to this hoping it would work but it didnt, values are blank.

<?php
        			$adquery = "SELECT * FROM ad_space WHERE id=1";
        			$adresult = mysql_query($adquery);
        			$adrow = mysql_fetch_assoc($adresult);
        			for($i=1;$i<6;$i++){
        				$var = "link".$i;
        				$var2 = "image".$i;
        				if($row['link'.$i] == '') {
        					$row['link'.$i] = '#';
        				}
        				echo "<a href=\"$row[$var]\" target=\"_blank\"><img src=\"$row[$var2]\" alt=\"$i\" /></a>";
        			}
        		?>

 

As always, any help is appreciated.

 

Thanks,

Justin

Link to comment
Share on other sites

not very pretty but should work

 

$row = mysql_fetch_assoc($adresult); //changed $adrow to $row

    for($i=1;$i<6;$i++){

        if($row['link'.$i] == '') {

          $row['link'.$i] = '#';

        }

    echo "<a href=\"".$row['link'.$i]."\" target=\"_blank\"><img src=\"".$row['image'.$i]."\" alt=\"$i\" /></a>"; //use of string concat operator: . [period]

}

 

 

edit: looks like if you just rename $adrow to $row in your second bit of code should work...

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.