Unholy Prayer Posted August 17, 2006 Share Posted August 17, 2006 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 https://forums.phpfreaks.com/topic/17815-unexpected-t-variable/ Share on other sites More sharing options...
Jeremysr Posted August 17, 2006 Share Posted August 17, 2006 I don't see anything wrong with it, but it might be the line above or below line 4...I think if you missed a semi-colon on line 3 it'd say that it is an error on line 4. Link to comment https://forums.phpfreaks.com/topic/17815-unexpected-t-variable/#findComment-76065 Share on other sites More sharing options...
trq Posted August 17, 2006 Share Posted August 17, 2006 Going to need a few lines around line 4. Php syntax errors are not line accurate. Link to comment https://forums.phpfreaks.com/topic/17815-unexpected-t-variable/#findComment-76066 Share on other sites More sharing options...
Unholy Prayer Posted August 17, 2006 Author Share Posted August 17, 2006 This is the whole page:[code]<?phprequire_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 https://forums.phpfreaks.com/topic/17815-unexpected-t-variable/#findComment-76068 Share on other sites More sharing options...
trq Posted August 17, 2006 Share Posted August 17, 2006 Your missing the colon from the end of your only echo() line. Link to comment https://forums.phpfreaks.com/topic/17815-unexpected-t-variable/#findComment-76069 Share on other sites More sharing options...
trq Posted August 17, 2006 Share Posted August 17, 2006 And also from the require_once() line. Link to comment https://forums.phpfreaks.com/topic/17815-unexpected-t-variable/#findComment-76070 Share on other sites More sharing options...
trq Posted August 17, 2006 Share Posted August 17, 2006 Jeremysr, a simple yes / no. Do you understand the meaning of your (our) avitar? Link to comment https://forums.phpfreaks.com/topic/17815-unexpected-t-variable/#findComment-76071 Share on other sites More sharing options...
Unholy Prayer Posted August 17, 2006 Author Share Posted August 17, 2006 Ok, that's wierd because semicolons have never been a problem in my other scripts in both the require_once() and echo lines. Where exactly do I put them? Just at the end? Link to comment https://forums.phpfreaks.com/topic/17815-unexpected-t-variable/#findComment-76072 Share on other sites More sharing options...
Jeremysr Posted August 17, 2006 Share Posted August 17, 2006 [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 https://forums.phpfreaks.com/topic/17815-unexpected-t-variable/#findComment-76074 Share on other sites More sharing options...
Unholy Prayer Posted August 17, 2006 Author Share Posted August 17, 2006 Oh, silly me. I was thinking of : instead of ; Lol. I am officially embarressed. Link to comment https://forums.phpfreaks.com/topic/17815-unexpected-t-variable/#findComment-76075 Share on other sites More sharing options...
trq Posted August 17, 2006 Share Posted August 17, 2006 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]<?phprequire_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 https://forums.phpfreaks.com/topic/17815-unexpected-t-variable/#findComment-76076 Share on other sites More sharing options...
Unholy Prayer Posted August 17, 2006 Author Share Posted August 17, 2006 Ok, there's no error now, but it's not displaying anything... Here it is:http://www.mutant-designs.com/programs/index.phpNote: That is the correct URL, I just forgot to add the "affiliates" directory and put all the files in it. I'll get to it when I'm done with the program. Link to comment https://forums.phpfreaks.com/topic/17815-unexpected-t-variable/#findComment-76078 Share on other sites More sharing options...
trq Posted August 17, 2006 Share Posted August 17, 2006 You never check to see if your query actually works before using it. Get in the habbit.[code=php:0]<?phprequire_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 https://forums.phpfreaks.com/topic/17815-unexpected-t-variable/#findComment-76082 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.