运行php脚本时遇到大量错误

编程入门 行业动态 更新时间:2024-10-28 08:26:08
本文介绍了运行php脚本时遇到大量错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

您好!好奇,如果有人能帮我一把。我写了这个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脚本时遇到大量错误

本文发布于:2023-10-16 00:46:12,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1495980.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:脚本   错误   php

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!