Skip to content
WJunction - Webmaster Forum

php error

Status
Not open for further replies.
im getting this error,i cant find the problem with it

"parse error syntax error unexpected t_constant_encapsed_string on line 1"

this is the random.php

PHP:
<?php
require_once '../../config.php';
include ('../../includes/core.php');

// Include language file
include '../../language/'.$setting['language'].'.php';
include '../../'.$setting['template_url'].'/template_settings.php';

$sql = mysql_query("SELECT * FROM ava_games WHERE published=1 ORDER BY rand() LIMIT 1") or die(mysql_error());
while($row = mysql_fetch_array($sql)) {
    
    $url = GameUrl($row['id'], $row['name'], $row['category_id']);
        
    $name = shortenStr($row['name'], $template['module_max_chars']);
    
    if ($setting['module_thumbs'] == 1) {
        $image_url = GameImageUrl($row['image'], $row['import'], $row['url']);
        $image = '<img src="'.$image_url.'" width= 100 height= 100 style="vertical-align: middle;" /> ';
    }
    else {
        $image = '';
    }
    
    echo '<center><a href="'.$url.'" title="Play '.$name.'">'.$image.'</a></center>';
}
?>
appretiate it if someone could advise
 

22 comments

The best method for fixing “parse errors” is to find the line which PHP is saying caused the error.

Parse error: parse error, unexpected T_STRING in /home/virtual/site5/fst/var/www/html/akash/errors.php on line 1

As you can see in the example above the number displayed at the end saying “on line 11” is the suspected location of the error. To find this line you can count down the lines of code including white space (made by the return key) to located the suspected line.

If you notice that you have missed one of the semi-colons “;” then inset one and test the code once more to see if all the errors have been resolved

However if the line number mentioned happens to be at the end of your code, then you will have to go back and look through out all your code to see if all the { } and “ ” are set up properly

To find them more easily you can use the find facility that is available in most editors including notepad for windows.

If you have a more sophisticated editor they usually highlight anything inside the quotation marks “ “ a different colour. If you like to make your code laid out in the right manner then you can use tab on all the { } to make sure they line up as this will allow you to spot the missing brackets quickly

thanks :)
 
ya i can copy paste to.. thanks. i cant find the problem in teh php on line 1 as suggested in the error on my site

here is the error on my site
bjs0r6.png
 
Can I assume this has been given to you & you want to use it on your board?
If so check the path is correct on line 1 & the others
 
well seems the one tht wrote this doesnt want to give any support on this question.. here is everything tht was included to get this to work

this is added to Header.php

PHP:
<script type="text/javascript">
$("#responsecontainer").load("includes/modules/random.php");
var refreshId = setInterval(function()
{
$('#responsecontainer').fadeOut('slow').load('includes/modules/random.php').fadeIn('slow');
}, 5000);
$.ajaxSetup({ cache: false });
</script>


then to call the random.php it is

<div id="responsecontainer"></div>
 
Strange :/ why will it give a parse error on line 1 when there is only the opening tag :s

You opening the file in? :s (if its wordpad then maybe it added some shit :p)
 
nope im using notepad++ ... i thought the same thing why its throwing out an error such as that right at the opening tag
 
If I remember correctly Line 0 is <?php
So maybe you have a lame PHP version try encasing your includes and require_once with parentheses rather than blatantly '../../config.php' crap

Like so:
require_once('../../config.php');

Could be wrong..too lazy to test

EDIT:
Also...could be wrong..but you might have short tags disabled in your php version which <?php would cause the error, so replace <?php with just <?

Once more..could be wrong xD
 
add a line to enable full error reporting, maybe that will help see what the problem is.

error_reporting(E_ALL);


or check the server/hosting error log. (cpanel user panel has error log) for some more info
 
Status
Not open for further replies.

About the author

iMage
Active Member · Joined
2,842
Messages
297
Reactions
83
Points

Advertise on WJunction

Reach 1000's of webmasters, hosts & affiliates. Banner & sponsored-thread slots available.

Contact us
Back
Top Bottom