易截截图软件、单文件、免安装、纯绿色、仅160KB

php mysqli 使用prepare

  1,绑定参数
 
  $mysqli=new mysqli($host,$user,$pass,$db);  
   if(mysqli_connect_errno()){  
    echo '连接出现异常了:'.mysqli_connect_error();  
    exit(0);  }  
      
   $sql = 'insert into user(name,pass,email) values(?,?,?)';  
   $stmt = $mysqli->prepare($sql);  
   $stmt->bind_param('sss',$name,$paassword,$email);  
   $name= '2';  
   $paassword=md5('12345');  
   $email = 'iamtsgx08@google.com';     
   $stmt->execute();  
     
   echo '修改了'.$stmt->affected_rows.'行';  
     
   $stmt->close();  
   $mysqli->close();
2,绑定结果集
$sql = 'select name,pass,email from user';  
  if($stmt = $mysqli->prepare($sql)){  
    $stmt->execute();  
    $stmt->bind_result($name,$pass,$email); //绑定结果  
    echo "<table>";  
    while($stmt->fetch()){  
        echo "<tr>";  
        echo "<td>".$name."</td>";  
        echo "<td>".$pass."</td>";  
        echo "<td>".$email."</td>";  
        echo "</tr>";  
    }  
    echo "</table>";  
    $stmt->close();  
  }  
   &nbs


相关文档:

apache and php common tips and problems

When I deploy php application on apache, some problem come out, and solved. Here's the tips and problems solved.
0.How could I deploy an apache server armed with php, mysql, perl, and phpMyAdmin on the fly?
You need a package bundled with all these tools,  xampp shall meet you needs, you can ......

PHP学习笔记1

1,Notice: Undefined variable解决办法
PHP默认配置会报这个错误,我的PHP版本是5.2.9-1,存在这个问题:
Notice: Undefined variable
这就是将警告在页面上打印出来,虽然这是有利于暴露问题,但实现使用中会存在很多问题。
需要设置显示错误级别,来解决问题。
网络上的通用解决办法是修改php.ini的配置:
解决方法 ......

Smarty 模板 从php分配的变量 数组

index.php:
$smarty = new Smarty;
$smarty->assign('Contacts',
array('555-222-9876',
'zaphod@slartibartfast.com',
array('555-444-3333',
'555-111-1234')));
$smarty->display('index.tpl');
index.tpl:
{$Contacts[0]}<br>
{$Contacts[1]}<br>
{* you can print arrays of arrays ......

分享几个php时间相关的函数

function FormatShowTime($nTotalSec)
{
//echo "total sec:" . $nTotalSec . '<br>';

$strTime = "";
//day
if ($nTotalSec > 3600 * 24)
{
$nDay = (int)($nTotalSec / (3600 * 24));
//$nDay > 0 ? $nDay : 1;
$strTime = $nDay;
$strTime .= '天';
//echo "nDay: ......

通用PHP动态生成静态HTML网页的代码

最近研究PHP的一些开发技术,发现PHP有很多ASP所没有的优秀功能,可以完成一些以前无法完成的功能,例如动态生成HTML静态页面,以减少服务器CPU的负载,提高用户访问的速度。
  我们知道,PHP读取MYSQL动态显示,在访问量大的情况下,会有很多性能问题,如果租用别人的虚拟主机,则会因为CPU消耗过多而被限制CPU,导致网 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号