开发者

Can't get results from mySQL query to display in PHP

I am very new to PHP and can't seem to use mySQL data at all from PHP. The SQL query I wrote works fine in phpMyAdmin when I run it in the SQL editor, but the most I am able to get from the code is the following from var_dump. Nothing else displays anything at all.

resource(3) of type (mysql result)

Any help at all would be greatly appreciated!!

<?php


    ini_set(‘display_errors’,1);
    error_reporting(E_ALL开发者_如何学JAVA|E_STRICT);

    $con = mysql_connect("localhost","XXXXXXXX","XXXXXXX");
    if (!$con) {
      die('Could not connect: ' . mysql_error());
      }

    mysql_select_db("sharetrader", $con);

    $sharelist = mysql_query("SELECT DISTINCT tblStocks.stockSymbol, tblShareData.lookupDate FROM tblStocks LEFT JOIN tblShareData ON tblShareData.tickerCode = tblStocks.stockSymbol ORDER BY tblShareData.lookupDate ASC LIMIT 0 , 30");

    if (!$sharelist) {
      die('Invalid query: ' . mysql_error());
      }

    var_dump($sharelist);

    while ($row = mysql_fetch_array($sharelist)) {
      echo $row['tblStocks.stockSymbol'];
      }

mysql_close($con);

?>


I am very new to PHP

But you're making great progress - just missing some of the finer points.

try:

while ($row = mysql_fetch_array($sharelist)) {
  var_dump($row);
}

...and it should be obvious what's happening.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜