php配置有关问题小结
php配置问题小结
在利用php+Apache+myslq进行编程的时候,经常有一个比较让人头疼的问题,就是配置php.ini文件。
?
问题1: Fatal error: Call to undefined function mysql_connect() in...
先用打印出信息,然后再查看是否已经有MYSQL的相关选项.如果没有说明PHP.INI配置有问题.修改!
?
编辑php.ini,寻找extension_dir,改为
extension_dir = "E:\Apache Software Foundation\php-5.2.5-Win32\ext"这样。注意用单个反斜线,注意整体用双引号装起来,
注意每个字母包括双引号冒号和空格都不要搞成全角了。然后记得检查你自己的那个目录下要确实有php_mysql.dll这个文件。
?最后在脚本里,注意每个字母都要是半角的。
还要注意启动PHP的方式,调用的要确实是你修改的这个php.ini
还要注意如果是APACHE+PHP的,改了php.ini之后最好重启动一下APACHE
?
以上是在网上找到的一些参照方法,我使用的是appserv安装包,所以关于php.ini里面的配置基本已经预先被配置好了,不用再改动,除非你后来改动了,会显示以上红色部分的信息。 当然,如果确定没有改动什么依然出现上述问题,可以尝试按照提供的方法进行改动,基本就是去掉注释和路径的配置两个方面,如果这样还不行,就将e:\php\ext加入环境变量的path中,e:\php\是你安装php的目录。还不行,就重启一下电脑。
?
?问题2: mysql_fetch_object(): supplied argument is not a valid MySQL result resource
?主要问题是mysql_fetch_object()函数里面的参数问题。多半是sql语句的语法问题。注意检查sql语句是否为空,语法格式是否正确
$userid=$_GET['userid']; $userid=trim($userid); $link=mysql_connect("localhost","root","root"); mysql_query("set names 'gbk'"); mysql_select_db(student); $sql="select * from stuinfo where userid='$userid'"; $result=mysql_query($sql); while($rs=mysql_fetch_object($result)){ $userid=$rs->userid; $password=$rs->password; $sex=$rs->sex; $city=$rs->city; $email=$rs->email; }
?
?
?
?
?

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



PHP and Python each have their own advantages, and choose according to project requirements. 1.PHP is suitable for web development, especially for rapid development and maintenance of websites. 2. Python is suitable for data science, machine learning and artificial intelligence, with concise syntax and suitable for beginners.

To set up a CGI directory in Apache, you need to perform the following steps: Create a CGI directory such as "cgi-bin", and grant Apache write permissions. Add the "ScriptAlias" directive block in the Apache configuration file to map the CGI directory to the "/cgi-bin" URL. Restart Apache.

The steps to start Apache are as follows: Install Apache (command: sudo apt-get install apache2 or download it from the official website) Start Apache (Linux: sudo systemctl start apache2; Windows: Right-click the "Apache2.4" service and select "Start") Check whether it has been started (Linux: sudo systemctl status apache2; Windows: Check the status of the "Apache2.4" service in the service manager) Enable boot automatically (optional, Linux: sudo systemctl

PHP is still dynamic and still occupies an important position in the field of modern programming. 1) PHP's simplicity and powerful community support make it widely used in web development; 2) Its flexibility and stability make it outstanding in handling web forms, database operations and file processing; 3) PHP is constantly evolving and optimizing, suitable for beginners and experienced developers.

To delete an extra ServerName directive from Apache, you can take the following steps: Identify and delete the extra ServerName directive. Restart Apache to make the changes take effect. Check the configuration file to verify changes. Test the server to make sure the problem is resolved.

There are 3 ways to view the version on the Apache server: via the command line (apachectl -v or apache2ctl -v), check the server status page (http://<server IP or domain name>/server-status), or view the Apache configuration file (ServerVersion: Apache/<version number>).

How to view the Apache version? Start the Apache server: Use sudo service apache2 start to start the server. View version number: Use one of the following methods to view version: Command line: Run the apache2 -v command. Server Status Page: Access the default port of the Apache server (usually 80) in a web browser, and the version information is displayed at the bottom of the page.

Apache connects to a database requires the following steps: Install the database driver. Configure the web.xml file to create a connection pool. Create a JDBC data source and specify the connection settings. Use the JDBC API to access the database from Java code, including getting connections, creating statements, binding parameters, executing queries or updates, and processing results.
