我正在使用PHP和MySQL数据库。
$con=mysql_connect("localhost","XYZ","pqr") or die("Failed to connect with database!!!!");
mysql_select_db("LMN", $con);
//Code and SQL query to find out the User transactions count of all types from beginning till today's date
$sql =" SELECT COUNT(*) `carried out`, SUM(transaction_status = 'success') `success`, ";
$sql .=" SUM(transaction_status = 'inprocess') `inprocess`, SUM(transaction_status = 'fail') `fail`, ";
$sql .=" SUM(transaction_status = 'cancelled') `cancelled` FROM OCN.user_transaction ";
$result = mysql_query($con,$sql);
echo $result; die;
$r = mysql_fetch_array($result);
如果我要echo $result
,则会出现空白屏幕。我没有得到这个代码的错误吗?任何人都可以帮我识别错误吗?
答案 0 :(得分:0)
$result = mysql_query($sql) or die(mysql_error());
$r = mysql_fetch_array($result, MYSQL_ASSOC);
print_r($r);