通过疯狂的域连接到mysql数据库时出错 [英] error connecting to mysql database through crazy domains

查看:48
本文介绍了通过疯狂的域连接到mysql数据库时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

新手在这里!我在自己的网站上做了一个简单的表格

newbie here! I have made a simple form on my site

警告消息

我似乎无法弄清楚我做错了什么.

I can't seem to figure out what i've done wrong.

这是php代码:

<?php
$servername = "localhost";
$dbusername = "charityh_root";
$dbpassword = "";
$dbname = "charitydb";

$fname = $_POST['fname'];
$lname = $_POST['lname'];
$state = $_POST['state'];
$email = $_POST['email'];

//$password = $_POST['password'];
//$sha1password = sha1($password);

//Create connection

$conn = new mysqli($servername, $dbusername, $dbpassword, $dbname);

//Check connection
If ($conn -> connect_error) {
die("Connection failed:" . $conn -> connect_error);

}

第17行是$conn = newmysqli($...

有什么主意吗?

MySQL数据库向导

现在连接到数据库,尽管当我输入详细信息(名字,姓氏,州和电子邮件)时,我得到的消息名字不能留为空白...

Connecting to database now although when i enter in the details (first name, last name, state and email) i get the message first name can not be left blank...

if (empty($fname)) {
    Echo "First name can not be blank. Please press back and correct the 
    issue";
    die();

 }

 if (empty($lname)) {
Echo "Last name can not be blank. Please press back and correct the issue!";
die();

}

if (empty($state)) {
  Echo "State can not be blank. Please press back and correct the issue!";
  die();

}

if (empty($email)) {
    Echo "Email can not be blank. Please press back and correct the issue!";
die();

}

$sql = "INSERT INTO charityh_database (First_Name, Last_Name, State, Email)
VALUES ('$fname', '$lname', '$state', '$email')";

  if ($conn->query($sql) === TRUE) {
    echo "Thank You";
    } else {
    echo "Error: " . $sql . "<br>" . $conn->error;
    }

  $conn->close ();

   ?>

推荐答案

$dbusername = "charityh_root";
$dbpassword = "";

似乎您使用的本地用户名和密码与本地服务器中使用的用户名和密码相同.您需要将其替换为用户名和密码疯狂域.

Seems like you are using the same username and password as you were using in your local server. You need to replace them with the username and password crazy domain's.

据我所知,疯狂域(Crazy Domain)不允许输入空白密码.

Since as far as I know Crazy Domain deosn't allows a blank password.

编辑 除此之外,我还能看到您在代码中提到的数据库名称是"charitydb";应该类似于charityh_database.(通过查看您最近的编辑,这是一个疯狂的猜测)

EDIT Besides that I can see the database name you have mentioned in the codes is "charitydb"; which should be something like charityh_database.(By looking at your recent edit this is a wild guess)

这篇关于通过疯狂的域连接到mysql数据库时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆