Jump to content

Unexpected T VARIABLE?


Unholy Prayer

Recommended Posts

Ok, I am trying to make an affiliates management program, but I keep getting this error on the index display page... here it is:
[code]Parse error: syntax error, unexpected T_VARIABLE in /home/mutantde/public_html/programs/index.php on line 4[/code]

This is line 4:
[code]$result = mysql_query("SELECT * from affiliates");[/code]

This is probably a noob question, but this is my first PHP program so I guess I am a PHP Noob.

Thanks in advance for the help.
Link to comment
Share on other sites

This is the whole page:
[code]<?php
require_once('database.php')

$result = mysql_query("SELECT * from affiliates");

while($r=mysql_fetch_array($result))
{  
  $site_name=$r["site_name"];
  $site_url=$r["site_url"];
  $banner_url=$r["banner_url"];
  echo "<a href='$site_url' target='new'><img src='$banner_url' width='88' height='31'></a>"
}
?>[/code]

I know... not that much coding, right?  But hey, with a PHP noob like me, this kind of stuff is expected.
Link to comment
Share on other sites

[quote author=thorpe link=topic=104587.msg417245#msg417245 date=1155795777]
Jeremysr, a simple yes / no. Do you understand the meaning of your (our) avitar?
[/quote]

Yes. I read the "How to be a Hacker" article and the emblem faqs.

And Unholy Prayer, semi-colons signify the end of a line.
Link to comment
Share on other sites

Jeremysr, cool. I have the book.

[quote]that's wierd because semicolons have never been a problem in my other scripts[/quote]

You should have... there are a required part of php synatx.

Yes, you'll need them at the end.
[code=php:0]
<?php
require_once('database.php');

$result = mysql_query("SELECT * from affiliates");

while($r=mysql_fetch_array($result))
{  
  $site_name=$r["site_name"];
  $site_url=$r["site_url"];
  $banner_url=$r["banner_url"];
  echo "<a href='$site_url' target='new'><img src='$banner_url' width='88' height='31'></a>";
}
?>
[/code]
Link to comment
Share on other sites

You never check to see if your query actually works before using it. Get in the habbit.

[code=php:0]
<?php
require_once('database.php');

if ($result = mysql_query("SELECT * from affiliates")) {
  while($r=mysql_fetch_array($result))
    $site_name=$r["site_name"];
    $site_url=$r["site_url"];
    $banner_url=$r["banner_url"];
    echo "<a href='$site_url' target='new'><img src='$banner_url' width='88' height='31'></a>";
  }
} else {
  echo "query failed ".mysql_error();
}
?>
[/code]
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.