Jump to content

unexpected T_STRING in this short Query


Modernvox

Recommended Posts

would this help you?

<?php
include('connect.php');
$result = mysql_query("SELECT itemQty SUM(itemQty) FROM transactions Where itemDescription= 'raffle'") or die mysql_error());
$row = mysql_fetch_array( $result );

echo $row['sum(itemQty)'];
?>

 

: ) i added $result = before you mysql_query();

would this help you?

<?php
include('connect.php');
$result = mysql_query("SELECT itemQty SUM(itemQty) FROM transactions Where itemDescription= 'raffle'") or die mysql_error());
$row = mysql_fetch_array( $result );

echo $row['sum(itemQty)'];
?>

 

: ) i added $result = before you mysql_query();

 

Nope. Thanks for trying though:-)

Hmm I have closed my sql to test it, but arent you missing a loop at the bottom to run through the array of results?

 

does maybe this work for you?

 

<?php
include('connect.php');
$result = mysql_query("SELECT itemQty SUM(itemQty) FROM transactions Where itemDescription= 'raffle'") or die mysql_error());

while ($row = mysql_fetch_array( $result )){
echo $row['sum(itemQty)'];
}
?>

 

if this doesnt work It might be the ['sum(itemQty)'] that is weird. But i hope this works :)

Hmm I have closed my sql to test it, but arent you missing a loop at the bottom to run through the array of results?

 

does maybe this work for you?

 

<?php
include('connect.php');
$result = mysql_query("SELECT itemQty SUM(itemQty) FROM transactions Where itemDescription= 'raffle'") or die mysql_error());

while ($row = mysql_fetch_array( $result )){
echo $row['sum(itemQty)'];
}
?>

 

if this doesnt work It might be the ['sum(itemQty)'] that is weird. But i hope this works :)

 

Nope. Still nothing. I have tried $row['itemQty']; 

This could be nothing but i just googled for http://www.parse-error-unexpected-t-string.com/ and if i look at your code Maybe a ( is missing right after the or die clause

 or die mysql_error());

instead of

 or die (mysql_error());

 

So maybe this is correct now:

<?php
include('connect.php');
$result = mysql_query("SELECT itemQty SUM(itemQty) FROM transactions Where itemDescription= 'raffle'") or die (mysql_error());

while ($row = mysql_fetch_array( $result )){
echo $row['sum(itemQty)'];
}
?>

This could be nothing but i just googled for http://www.parse-error-unexpected-t-string.com/ and if i look at your code Maybe a ( is missing right after the or die clause

 or die mysql_error());

instead of

 or die (mysql_error());

 

So maybe this is correct now:

<?php
include('connect.php');
$result = mysql_query("SELECT itemQty SUM(itemQty) FROM transactions Where itemDescription= 'raffle'") or die (mysql_error());

while ($row = mysql_fetch_array( $result )){
echo $row['sum(itemQty)'];
}
?>

 

Yep. That eliminated the error. Thank you. Although it still returns 0 results i at least know what u pointed out:-)

Can't fix it?

 

<?php
include('connect.php');
mysql_query("SELECT itemQty SUM(itemQty) FROM transactions Where itemDescription= 'raffle'") or die mysql_error());
$row = mysql_fetch_array( $result );

echo $row['sum(itemQty)'];
?>

 

you are missing a , after itemQty... your select should read

mysql_query("SELECT itemQty, SUM(itemQty) AS TitemQty FROM transactions Where itemDescription= 'raffle'") or die (mysql_error());

notice that I also added an alias for the aggregate function... it will allow you to change this line

echo $row['sum(itemQty)'];

for the more simple

echo $row['TitemQty'];

Can't fix it?

 

<?php
include('connect.php');
mysql_query("SELECT itemQty SUM(itemQty) FROM transactions Where itemDescription= 'raffle'") or die mysql_error());
$row = mysql_fetch_array( $result );

echo $row['sum(itemQty)'];
?>

 

you are missing a , after itemQty... your select should read

mysql_query("SELECT itemQty, SUM(itemQty) AS TitemQty FROM transactions Where itemDescription= 'raffle'") or die (mysql_error());

notice that I also added an alias for the aggregate function... it will allow you to change this line

echo $row['sum(itemQty)'];

for the more simple

echo $row['TitemQty'];

 

Ahhhh.. Absolutely. That works.. Thanks Guys for the tutorial!

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.