Home > Backend Development > PHP Tutorial > PHP能连接数据库但是不能create database,如何解决

PHP能连接数据库但是不能create database,如何解决

WBOY
Release: 2016-06-13 10:34:37
Original
1150 people have browsed it

PHP能连接数据库但是不能create database,怎么解决?
先贴代码:

PHP code
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--><?php $con = mysql_connect("localhost");if (!$con){    die('Could not connect: ' . mysql_errno());}else{    echo "success" . "<br />";}if (mysql_query("CREATE DATABASE hello", $con)){    echo "Database created";}else{    echo "ERROR";}mysql_close($con);?>
Copy after login

这段代码,我在zend下编写,运行环境是WAMP,运行结果是
success
ERROR

这意味着连接数据库没问题,但是执行CREATE DATABASE hello出错了。想不明白是怎么回事,求教一下大家。

------解决方案--------------------
看看有没权限创建数据库
------解决方案--------------------
你把 echo "ERROR";
改成 echo mysql_error();

就不要什么“意味着”了
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template