有没有办法让我的网站的旧布局与MYSQL一起使用新的MYSQLi?但我不是说用php回声“废话样式html”我的意思是跟随旧学校html轻松获得更好的视图和自定义简单设计:
这是代码示例:
<?php
mysql_connect ('localhost', 'gggggg', 'gggggg') ;
mysql_select_db ('ggggg');
$sql = "SELECT * FROM profiles WHERE username =".$_POST['profile'];
while($row = mysql_fetch_array($sql)) {
$username = stripslashes($row['username']);
$age = stripslashes($row['age']);
$gender = stripslashes($row['gender']);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>title</title>
</head>
<body>
CUSTOM HTML FOR A NICE DESIGN WITHOUT PRINTS OR CRAP JUST NICE AND EASY just like old school
CATEGORY <?php echo $username; ?>
TITEL <?php echo $age; ?>
CONTENT <?php echo $sex; ?>
</body>
</html>
<?php
}
?>
答案 0 :(得分:0)
mysql
和mysqli
之间存在一些细微的差异,但作为程序扩展,您应该能够完成您现在所做的几乎所有的工作。
例如:
<?php
$conn = mysqli_connect ('localhost', 'gggggg', 'gggggg') ; // $Connection needed for later calls
mysqli_select_db ($conn, 'ggggg'); // incloude the connection variable for each call
$sql = "SELECT * FROM profiles WHERE username =".$_POST['profile'];
$result = mysqli_query($conn, $query); // Connection variable required
while($row = mysqli_fetch_array($sql)) {
$username = stripslashes($row['username']);
$age = stripslashes($row['age']);
$gender = stripslashes($row['gender']);
您需要采取针对SQL注入的常规预防措施。您可能希望考虑使用准备好的声明。您还需要添加任何必要的错误检查。