标签:mysql htm roo html nec highlight type err rom
不返回结果集
<?php //使用对象属性和方法来插入数据 header(‘Content-type:text/html;carset=utf8‘); $con=new mysqli(‘localhost‘,‘root‘,‘123456‘,‘t3‘,3306); $str=‘insert into tech values (9,"刘海波",132789)‘; if($con->connect_error){ $con->connect_error(); } $con->set_charset(‘utf8‘); if($con->query($str)==true){ echo ‘插入数据成功‘; }else{ echo ‘ERRPR‘.$str.$con->error; } $con->close(); ?>
<?php //使用对象属性和方法来插入数据 header(‘Content-type:text/html;carset=utf8‘); $con=new mysqli(‘localhost‘,‘root‘,‘123456‘,‘t3‘,3306); $str=‘select * from tech‘; if($con->connect_error){ $con->connect_error(); } $con->set_charset(‘utf8‘); $result=$con->query($str); //fetch_assoc 返回数组 while($jieguo=$result->fetch_assoc()){ echo $jieguo[‘id‘].‘-------‘.$jieguo[‘name‘].‘---------‘.$jieguo[‘pwd‘].‘--------‘.‘<br>‘; } $con->close(); ?>
标签:mysql htm roo html nec highlight type err rom
原文地址:https://www.cnblogs.com/xiaowie/p/11949197.html