下面这段代码,为什么不会输出我想要的数据?
<?
//连接到本地mysql数据库
$myconn=mysql_connect("localhost","root","");
//选择test为操作库
mysql_select_db("test",$myconn);
$fir='select * from first where id=2';
$sec='select * from second where id=3';
//
?>
<li><?echo $fir.$sec?></li>
<li><?echo $fir.$sec?></li>输出如下:
select * from first where id=2select * from second where id=3 select * from first where id=2select * from second where id=3
<?
//连接到本地mysql数据库
$myconn=mysql_connect("localhost","root","");
//选择test为操作库
mysql_select_db("test",$myconn);
$fir='select * from first where id=2';
$sec='select * from second where id=3';
//
?>
<li><?echo $fir.$sec?></li>
<li><?echo $fir.$sec?></li>输出如下:
select * from first where id=2select * from second where id=3 select * from first where id=2select * from second where id=3
// Connecting, selecting database
$myconn = mysql_connect('localhost', 'root', '')
or die('Could not connect: ' . mysql_error());
echo 'Connected successfully';
mysql_select_db('test',$myconn) or die('Could not select database');// Performing SQL query
$query = 'select * from first where id=2';
$result = mysql_query($query) or die('Query failed: ' . mysql_error());// Printing results in HTMLwhile ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
foreach ($line as $col_value) {
echo "<li>$col_value</li>\n";
}
}// Free resultset
mysql_free_result($result);// Closing connection
mysql_close($myconn);
?>
<?
$myconn=mysql_connect("localhost","root","");
mysql_select_db("test",$myconn);
$fir='select * from first where id=2';
$sec='select * from second where id=3';
$result1=$myconn.query($fir);
$result2=$myconn.query($sec);
$row1 = $result1->fetch_row();
$row2 = $result2->fetch_row();
?>
<li> <?echo $row1[0].$row2[0]?> </li> <li> <?echo $row1[0].$row2[0]?> </li>
省去了很多判断语句,仅供功能测试
Fatal error: Call to a member function on a non-object in d:\usr\www\html\showname.php on line 60
请问:->这是运算符吗?是什么意思?我刚接触Php,还请赐教,谢谢!
Fatal error: Call to a member function on a non-object in d:\usr\www\html\showname.php on line 62请教!
$row1 = mysql_fetch_row($result1);