Jump to content

unexpected T error


RyanSF07

Recommended Posts

Hello,

 

I'm getting an "unexpected T-variable" error on the $all = SELECT line. 

 

I've gut this down to nothing. 

 

What is throwing the error?

 

while($row = mysql_fetch_array($result)) {

$all = "SELECT * FROM video ORDER BY id";

$result = mysql_query($all);

etc. etc

}

 

thank you for your help,

Ryan

Link to comment
https://forums.phpfreaks.com/topic/224378-unexpected-t-error/
Share on other sites

Same thing -- unexpected T-variable

 

Here's the code.  I'm trying to pull content from the database and place it in an HTML table.

 

Thank you for your help!

 

function imageResize($width, $height, $target) {

if ($width > $height) {
$percentage = ($target / $width);
} else {
$percentage = $height == 0? 0 : $target / $height;
}

$width = round($width * $percentage);
$height = round($height * $percentage);
return "width=\"$width\" height=\"$height\"";
}

while($row = mysql_fetch_array($result)) {

$rs = "SELECT * FROM video ORDER BY id";

$num = mysql_numrows($result);


$result = mysql_query($rs);
$tdcount = 1; 

$numtd = 4; // number of cells per row

$table_content .=  "<table>"; 

while($row = mysql_fetch_array($result)<$num) {

if ($tdcount == 1) $table_content .= "<tr>"; 
$table_content .= "<td><p><a href='view.php?id=" . $row['id'] . "'><img src='http://www.site.com/images/". $row['photo'] ."' " . imageResize($resized[0], $resized[1], 100) ."></a><br>" . $row['title'] . "<br>views " . $row['counter'] . "<br>".  ThumbsUp::item($row['id'])->template('mini_thumbs')->format('{UP}↑↓{DOWN}') ."</td>";  

if ($tdcount == $numtd) { 
$table_content .=  "</tr>"; 

$tdcount = 1; 

} else { 

$tdcount++; 
}

} 

//close table 

if ($tdcount!= 1) { 

while ($tdcount <= $numtd) { 
$table_content .=  "<td> </td>"; 
$tdcount++; 

} $table_content .=  "</tr>"; 

} 
$table_content .=  "</table>";

include_once ("template_test.inc"); 

?>

Link to comment
https://forums.phpfreaks.com/topic/224378-unexpected-t-error/#findComment-1159159
Share on other sites

Thank you Pikachu.

 

I removed them.

 

Now the error I'm getting is:  Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource  (1st line in code snip below). My select query is abbreviated here -- but I don't think that's the problem.

 

Thank you again for your help.

 

while($row = mysql_fetch_array($result)) {
$rs = "SELECT * video ORDER BY id DESC";

$result = mysql_query($rs);
$num = mysql_numrows($result);
$tdcount = 1;
$numtd = 4; // number of cells per row

$table_content .=  "<table>";
while($row = mysql_fetch_array($result)<$num) {

if ($tdcount == 1) $table_content .= "<tr>"; 
$table_content .= "<td><p><a href='view.php?id=" . $row['id'] . "'><img src='http://www.site.com/images/". $row['photo'] ."' " . imageResize($resized[0], $resized[1], 100) ."></a><br>" . $row['title'] . "<br>views " . $row['counter'] . "<br>".  ThumbsUp::item($row['id'])->template('mini_thumbs')->format('{UP}↑↓{DOWN}') ."</td>";  

if ($tdcount == $numtd) { 
$table_content .=  "</tr>";
$tdcount = 1;
} else {
$tdcount++;}
}
//close table
if ($tdcount!= 1) { 
while ($tdcount <= $numtd) { 
$table_content .=  "<td> </td>"; $tdcount++; 
} $table_content .=  "</tr>"; 
} $table_content .=  "</table>";
}
include_once ("template_test.php"); 

?>

Link to comment
https://forums.phpfreaks.com/topic/224378-unexpected-t-error/#findComment-1159178
Share on other sites

You and mikosiko are awesome.  Thank you so much for your help.

 

Excluding the FROM was my mistake -- I shouldn't have abbreviated the Select query. 

 

Miko -- I ditched that unneeded While query.  Thank you. Here's what I have now with my full Select query -- no errors -- but nothing displayed either. 

 

Any ideas?

 

$rs = "SELECT video.id, title, description_text, category_text, level_text, pass_text, user_name, 
DATE_FORMAT(date, '%M %D, %Y') as date FROM video, 
registered_users WHERE video.user_id = registered_users.id AND video.category_text = 'English' AND video.level_text = 'high-intermediate' AND video.pass_text = 'featured' ORDER BY id DESC";
$result = mysql_query($rs);



$tdcount = 1;
$numtd = 4; // number of cells per row

$table_content .=  "<table>";
while($row = mysql_fetch_array($result)<$numtd) {

if ($tdcount == 1) $table_content .= "<tr>"; 
$table_content .= "<td><p><a href='view.php?id=" . $row['id'] . "'><img src='http://www.site/images/". $row['photo'] ."' " . imageResize($resized[0], $resized[1], 100) ."></a><br>" . $row['title'] . "<br>views " . $row['counter'] . "<br>".  ThumbsUp::item($row['id'])->template('mini_thumbs')->format('{UP}↑↓{DOWN}') ."</td>";  

if ($tdcount == $numtd) { 
$table_content .=  "</tr>";
$tdcount = 1;
} else {
$tdcount++;}
}
//close table
if ($tdcount!= 1) { 
while ($tdcount <= $numtd) { 
$table_content .=  "<td> </td>"; $tdcount++; 
} $table_content .=  "</tr>"; 
} $table_content .=  "</table>";

include_once ("template_test.php"); 

?>

Link to comment
https://forums.phpfreaks.com/topic/224378-unexpected-t-error/#findComment-1159192
Share on other sites

add this 2 lines at the beginning of your code (after <?php) to enable display of errors

error_reporting(E_ALL); 
ini_set("display_errors", true);

 

now... what are you trying to do here? ...  ::)

while($row = mysql_fetch_array($result)<$numtd) {

 

and post your complete code... the portion that you posted has unmatched {}

Link to comment
https://forums.phpfreaks.com/topic/224378-unexpected-t-error/#findComment-1159482
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.