php连接数据库问题 文件上传图片写入数据库中:转码,从数据库读取怎么代码啊 。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 你转码存入数据库,读出来就要解码咯, PHP上传图片,在数据里面只要存入图片名称,名称可以用随机数加进去,网上有很多例子,你可以去找找看 二进制addslashes以后''引起来插入, 读的时候直接读到就是原先数据. 我写出来注册页面无法连接数据库怎么回事<?php$username=$_POST['username'];$password=$_POST['password'];$password=$_POST['password1'];$email=$_POST['email'];if(empty($username)||empty($password)||empty($password1)||empty($email)){ echo'<script>alter("注册中的每一项必须填写!")</script>'; } if($password!=$password1){ echo'<script>alter("两次输入的密码不一致")</script>'; } else{ if(empty($password)){ echo'<script>alter("密码不能为空")</script>'; } else { $sql="insert into users(username,password,email) VALUES('$username','$password','email')"; $rs=mysql_query($sql); if($rs) { header('location: ./landing.php'); } } }?><html> <head> <title>表单注册</title> </head> <body> <p align="center">用户注册</p> <form action="register.php" method="POST"> <table width="650" border="0" align="center" cellspacing="1" bgcolor="red"> <tr bgcolor="lavender"> <td>博客昵称:</td> <td colspan="2"><label><input type="username" name="username" ></label>*4~20为小写字母、数字或汉字(汉字算两位)组成</td> </tr> <tr bgcolor="lavender"> <td>登陆密码:</td> <td colspan="2"><label><input type="password" name="pssword" ></label>*6~10为字符(字母、数字、符号)区分大小写</td> </tr> <tr bgcolor="lavender"> <td>确认密码:</td> <td colspan="2"><label><input type="password" name="password1" ></label>*请输入与上一次相同的登录密码</td> </tr> <tr bgcolor="lavender"> <td>邮箱:</td> <td colspan="5"><label><input type="text" name="email">*请输入常用的邮箱地址</label></td> </tr> <tr> <tr bgcolor="lavender"> <td> </td> <td width="212"><input type="submit" name="submit" value="提交"> </td> <td width="250"><input type="submit" name="submit" value="取消"> </td> </tr> <tr> </label> </form> </body> </html> 不知道你有没有链接sql的语句,插入之前应该有没有关闭的数据库链接。还有$sql="insert into users(username,password,email) VALUES('$username','$password','email')";红色那是啥东西,应该$email吧 哦哦 我写出来注册页面无法连接数据库怎么回事$sql="insert into users(username,password,email) VALUES('$username','$password','$email')";这句话是这样的 那 mysql_connect 在哪里? 我是写在include('conn.php')中的 发到这上面的这个没用 我昨天重加了一次还是没法 <?php$conn=@mysql_connect('localhost','root','')or die ('数据库连接失败');mysql_select_db('blog',$conn);mysql_query('set names utf8');?>连接数据库的代码 zend debug,求教 ,~~~~~~~~~` php 表格問題 统计Id和价格相同时,数据相加,不同记录列出逻辑 php 中文登录的问题... 求一段正则 求一最快速度而又节省资源的方法 开发一个类似discuz的论坛要多长时间 求一网站开发中实际问题的解决思路,解决者或提出中肯意见者高分!!! 咨询一个PHP & 操作的问题 PHP与C语言之间的差异 两表数据插入的问题. 在简易的微博代码中怎么加入上传图片
<?php
$username=$_POST['username'];
$password=$_POST['password'];
$password=$_POST['password1'];
$email=$_POST['email'];
if(empty($username)||empty($password)||empty($password1)||empty($email)){
echo'<script>alter("注册中的每一项必须填写!")</script>';
}
if($password!=$password1){
echo'<script>alter("两次输入的密码不一致")</script>';
}
else{
if(empty($password)){
echo'<script>alter("密码不能为空")</script>';
}
else
{
$sql="insert into users(username,password,email) VALUES('$username','$password','email')";
$rs=mysql_query($sql);
if($rs)
{
header('location: ./landing.php');
}
}
}?>
<html>
<head>
<title>表单注册</title>
</head>
<body>
<p align="center">用户注册</p>
<form action="register.php" method="POST">
<table width="650" border="0" align="center" cellspacing="1" bgcolor="red">
<tr bgcolor="lavender">
<td>博客昵称:</td>
<td colspan="2"><label><input type="username" name="username" ></label>*4~20为小写字母、数字或汉字(汉字算两位)组成</td>
</tr>
<tr bgcolor="lavender">
<td>登陆密码:</td>
<td colspan="2"><label><input type="password" name="pssword" ></label>*6~10为字符(字母、数字、符号)区分大小写</td>
</tr>
<tr bgcolor="lavender">
<td>确认密码:</td>
<td colspan="2"><label><input type="password" name="password1" ></label>*请输入与上一次相同的登录密码</td>
</tr>
<tr bgcolor="lavender">
<td>邮箱:</td>
<td colspan="5"><label><input type="text" name="email">*请输入常用的邮箱地址</label></td>
</tr>
<tr>
<tr bgcolor="lavender">
<td> </td>
<td width="212"><input type="submit" name="submit" value="提交">
</td>
<td width="250"><input type="submit" name="submit" value="取消">
</td>
</tr>
<tr>
</label>
</form>
</body>
</html>
还有$sql="insert into users(username,password,email) VALUES('$username','$password','email')";
红色那是啥东西,应该$email吧
$sql="insert into users(username,password,email) VALUES('$username','$password','$email')";这句话是这样的
$conn=@mysql_connect('localhost','root','')or die ('数据库连接失败');
mysql_select_db('blog',$conn);
mysql_query('set names utf8');
?>
连接数据库的代码