LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 3595|回复: 19

测试apache +mysql +php

[复制链接]
发表于 2002-11-6 14:23:09 | 显示全部楼层 |阅读模式
我想在RH8下测试apache+php+mysql 能否正常 运行!
首先我在apache 默认的存放文档的目录下面建立了test.php,内容如下。
<?php>
phpinfo();
?>
在URL中输入http://localhost/text.php
可以看到很多信息。
然后我在Mysql下建立了一个名为test 的库;
并将以下文件导入 test
create table employees ( id tinyint (4) default '0' not null
auto_increment,first varchar (20), last varchar (20), address varchar (255),
positon varchar (50), primary key (id), unique id (id));
insert into employees values (1,'Bob','Smith','128 Here St,
Cityname','Marketing Manager');
insert into employees values (2,'John','Roberts','45 There St,Townvila',
'Telephonist');
insert into employees values (3,'Brad','Johnson','1/34 Nowhere Blvd,Snowston',
'Doorman');
最后建立一个test2.php文件,如下
<html>
<body>
<?php
$dbname = "test";
$db = mysql_connect("localhost", "root", "password");
mysql_select_db("test",$db);
$result = mysql_query("select * from employees",$db);
printf("First Name: %s<br>\n", mysql_result ($result,0,"first"));
printf("Last Name: %s<br>\n", mysql_result ($result,0,"last"));
printf("osition: %s<br>\n", mysql_result ($result,0,"position"));
?>
</body>
</html>
但在URL中输入http://localhost/test2.php确显示.
\n", mysql_result ($result,0,"first")); printf("Last Name: %s
\n", mysql_result ($result,0,"last")); printf("osition: %s
\n", mysql_result ($result,0,"position")); ?>
请问各位高手,这是 怎么回事呀?
发表于 2002-11-7 14:23:29 | 显示全部楼层
你贴上的代码是你从程序中拷贝出来的吗?不是吧?我想你肯定是把<br>写成了<br?>之类的东东。仔细看看吧。
 楼主| 发表于 2002-11-8 12:04:50 | 显示全部楼层
我就是从代码上粘下来的呀!
不过忘了说明一点,就是我用的是RH8自带的apache和php,只有mysql是编译安装的!
是不是mysql不能和它们结合呀!!请教!
发表于 2002-11-8 13:41:32 | 显示全部楼层
应该不是那个问题,你把程序发给我看看。
 楼主| 发表于 2002-11-8 18:45:36 | 显示全部楼层
请问是什么程序?
发表于 2002-11-11 09:17:41 | 显示全部楼层
你的test2.php
 楼主| 发表于 2002-11-15 15:18:07 | 显示全部楼层
以下是源程序,多谢了!
<html>
<body>
<?php
$dbname = "test";
$db = mysql_connect("localhost", "root", "4ever");
mysql_select_db("test",$db);
$result = mysql_query("select * from employees",$db);
printf("First Name: %s<br>\n", mysql_result ($result,0,"first"));
printf("Last Name: %s<br>\n", mysql_result ($result,0,"last"));
printf("osition: %s<br>\n", mysql_result ($result,0,"position"));
?>
</body>
</html>
 楼主| 发表于 2002-11-17 12:37:35 | 显示全部楼层
我知道怎么回事了,真是太大意了,我把test2.php写成了test2.php3
但现在又有了一个新问题,输入http://localhost/test2.php后提示如下
Fatal error: Call to undefined function: mysql_connect() in /var/www/html/test2.php on line 5
 楼主| 发表于 2002-11-17 18:55:50 | 显示全部楼层
我运行了php后出现如下信息
PHP Warning:  Unable to load dynamic library '/usr/lib/php4/mysql.so' - /usr//php4/mysql.so: cannot open shared object file: No such file or directory in
nown on line 0
在/usr/lib/php4/下,好像没有mysql.so这个东东?怎么办?
 楼主| 发表于 2002-11-18 12:48:35 | 显示全部楼层

谁有mysql.so文件呀?急!

php无法调用mysql的链接函数,原因是/usr/lib/php4下找不到mysql.so文件。
请好心人给小弟发一个 panzhongqianger@sohu.com 多谢呀!
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表