如何更改PHP脚本以使用PDO?

如何更改PHP脚本以使用PDO?,php,mysql,html,pdo,Php,Mysql,Html,Pdo,旧查询用于获取管理员存储在数据库中的网站设置,如MyCompanyName或版权文本。这些是管理员在站点后端添加的 <?php error_reporting (E_ALL ^ E_NOTICE); include("connection.php"); include('english.php'); include("admin/include/function.php"); $query_general_setting=mysql_fetch_array(mysql_quer

旧查询用于获取管理员存储在数据库中的网站设置,如MyCompanyName或版权文本。这些是管理员在站点后端添加的

<?php 

error_reporting (E_ALL ^ E_NOTICE);

include("connection.php");

include('english.php');

include("admin/include/function.php");

$query_general_setting=mysql_fetch_array(mysql_query("select * from general_setting where id=1 and g_id=1"));

if(basename(url())!="index.php" or basename(url())!="index.php?log=1"){

$explode_permistion=explode(",",$_SESSION['area_permistion']);

}



?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>

    <head>

        <meta name="viewport" content="width=device-width, maximum-scale=1, initial-scale=1, user-scalable=0">

        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>

        <meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible">

        <link href='http://fonts.googleapis.com/css?family=Exo+2&subset=latin,latin-ext' rel='stylesheet' type='text/css'>

        <link href="center/css/jquery/jquery-ui-1.10.3.custom.css" media="screen" rel="stylesheet" type="text/css" />

        <link href="center/css/center.css" media="screen" rel="stylesheet" type="text/css" />       

        <title><?php echo $query_store_setting['s_title'];?></title>

        <meta name="description" content="<?php echo $query_store_setting['s_description'];?>">

        <meta name="keywords" content="<?php echo $query_store_setting['s_keywords'];?>">

        <link rel="stylesheet" href="style.css"> 

</head>
要是只有一排就好了

$query_store_setting = $conn->query('SELECT * FROM general_setting WHERE id=1 and g_id=1')->fetch();
不止一个

$result = $conn->query('SELECT * FROM general_setting WHERE id=1 and g_id=1')->fetchAll();
 foreach($result as &$row) {
      $query_store_setting = $row;
      //do sth..
 }

您使用此查询仅获得1条记录?我已修复了格式不正确的隐藏代码。请在此学习如何使用格式化工具-您只需选择代码并按“代码”按钮。甚至还有一个预览窗格,所以没有理由发布未格式化的代码。嗨!是的,谢谢,你说得对。我在这里读了很多关于stackoverflow的文章,但从未提出过任何问题。很抱歉格式不正确。非常感谢您花时间回答。是的,目前只有一行。它现在正在实际工作。所以我错过的只是使用fetchAll()进行一行查询?
$result = $conn->query('SELECT * FROM general_setting WHERE id=1 and g_id=1')->fetchAll();
 foreach($result as &$row) {
      $query_store_setting = $row;
      //do sth..
 }