Jump to content

Recommended Posts

I am working on displaying some posts created by a user, grabing from a database, then looping through fields in the database displaying all the entries created in the table.

 

My problem is the file that holds the html output with the php code used to plug in the variables during the loop.

 

here is the error I am getting:

 

Parse error: syntax error, unexpected T_VARIABLE, expecting ',' or ';' in /home1/royalvil/public_html/comment_board/_view.php on line 13

 

I have seen this type before, and find them usually easy to fix, but this time, I have tried everything and the error doesnt change. Its now refering to a blank line with no code what so ever!

 

Here is the file that running the loop from the database:

 

<?php

ini_set('display_errors',1);
error_reporting(E_ALL);

include_once('com_db_fns.php');

db_connect();

/** Gathers data from database and processes time stamp
*	@return resource 
*/


$result = mysql_query("SELECT * FROM comtable ORDER BY post_id DESC"); 
	if (!$result) { 
	  echo("Error performing query: " . mysql_error() ); 
	  exit(); 
	} // end $result error check

while ($row = mysql_fetch_array($result) ) { 
	$msgTxt = $row["txt"];
	$msgId = $row["post_id"]; 
	$SigName = $row["name"];
	$SigDate = $row["time"];
	$msgTitle = $row["title"];
	$url = $row["email"];



// divides data taken from TIMEDATE stamp field 'time' into separate variables
$yr = substr($SigDate, 2, 2);
$mo = substr($SigDate, 4, 2);
$da = substr($SigDate, 6, 2);
$hr = substr($SigDate, 8, 2);
$min = substr($SigDate, 10, 2);

// converts military time (TIMEDATE default format) over to conventional time format
if ($hr > "11") {
	$x = "12";
	$timetype = "PM";
	$hr = $hr - 12;
	}else{
	$timetype = "AM";
}

// if user leaves email blank in form, email field $url takes a value of #
if (!$url) {
	$url = "#";
	}else{
	$stat = $url;
	$url = "mailto:" . $url . "";
}

// displays the data taken from the field
include_once('_view.php');

} // end while loop

?>

 

 

here is _view.php before I started gutting the php code to try and narrow down the problem:

 

the error refers to this line:

date created: <?php echo $hr.':'.$min $timetype; ?>

 

<table width="400" border="1">
<tr>
<td>
<h2><?php echo $msgTitle; ?></h2>
</td>
</tr>

<tr>
<td>
name: <?php echo '<a href="'.$url.'">'.$SigName.'</a>'; ?>

date created: <?php echo $hr.':'.$min $timetype; ?>

post id: <?php echo $msgId; ?>
</td>
</tr>

<tr>
<td>
comment: </br> <?php echo $msgTxt; ?>
</td>
</tr>
</table>

 

The file is connecting to the database fine and as you can see I have error reporting set to all, but I am not getting any extra info from it.

 

I hope you have some idea as to what is going on

Link to comment
https://forums.phpfreaks.com/topic/194982-unexpected-t_variable/
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.