运行php脚本时遇到大量错误 [英] Getting slew of errors when running php script
问题描述
您好!好奇,如果有人能帮我一把。我写了这个PHP
脚本,与一个名为
firstdb的mysql数据库建立了一个简单的连接,只需将结果撤回并显示在网页上。
这是脚本。
我很欣赏可以在脚本上散发的任何光线,以及为什么我会为b $ b获取错误。
谢谢,
迈克
-------------- -------------
< html>
< head>
< meta http-当量= QUOT;内容类型" content =" text / html;
charset = iso-8859-1">
< title>示例PHP脚本< / title>
< / head>
< body style =" font-family:Arial,Helvetica,sans-serif"
style =" background-color:#CC9966">
<?php
//定义连接字符串
$ host =" localhost";
$ user =" root";
$ pass =" *******";
//打开与数据库的持久连接
$ connect = mysql_connect($ host,$ user,$ pass);
//选择数据库
mysql_select_db(" myfirstdb",$ connect);
//设置并运行查询
$ sql ="选择Employee_no,Last_name,First_name,佣金来自
Sales_Representative" ;;
$ result = mysql_query($ sql,$ connect);
$ x = mysql_num_rows($ result);
//如果是第十名行存在,直接去吧
if($ x> = 10){
mysql_data_seek($ result,9);
}
//从第10行返回数据
$ row = mysql_fetch_array($ result);
打印" Employee_no : 。 $ row [" Employee_No"]。 "< br> \ n";
打印" Last_Name:" 。 $ row [" Last_Name"]。 "< br> \ n";
打印" First_Name:" 。 $ row [" First_Name"]。 "< br> \ n";
打印佣金:" 。 $ row [" Commission"];
?>
< / body>
< ; / html>
Hello! Curious if anyone could give me a hand. I wrote this PHP
script with makes a simple connection to a mysql database called
firstdb and just pulls back the results and displays on the webpage.
Here is the script.
I appreciate any light that could be shed on the script and why I would
get the errors.
Thank you,
Mike
---------------------------
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
<title>Sample PHP Script</title>
</head>
<body style="font-family:Arial, Helvetica, sans-serif"
style="background-color:#CC9966">
<?php
// Define connection string
$host = "localhost";
$user = "root";
$pass = "*******";
//open a persistant connection to the database
$connect = mysql_connect($host, $user, $pass);
//Select the database
mysql_select_db("myfirstdb", $connect);
//Set and run the query
$sql = "Select Employee_no, Last_name, First_name, Commission from
Sales_Representative";
$result = mysql_query($sql, $connect);
$x = mysql_num_rows($result);
//If the tenth row exists, go straight to it
if ($x >= 10) {
mysql_data_seek($result, 9);
}
//Return the data from the 10th row
$row = mysql_fetch_array($result);
Print "Employee_no: " . $row["Employee_No"] . "<br>\n";
Print "Last_Name: " . $row["Last_Name"] . "<br>\n";
Print "First_Name: " . $row["First_Name"] . "<br>\n";
Print "Commission: " . $row["Commission"];
?>
</body>
</html>
推荐答案
host =" localhost";
host = "localhost";
user =" root";
user = "root";
pass =" *******" ;;
/ /打开与数据库的持久连接
pass = "*******";
//open a persistant connection to the database
这篇关于运行php脚本时遇到大量错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!