数据库连接到活动网站 [英] Database Connection to live site

查看:182
本文介绍了数据库连接到活动网站的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在建立一个在线预订表单作为项目,一旦用户点击提交按钮,它发送一个电子邮件的详细信息到指定的电子邮件,并将一切存储在数据库中。目前这一切都工作正常,并在 localhost 设置。

I'm currently building an online booking form as a project and once the user hits the submit button it sends an email with the details to a specified email and stores everything in an database. Currently this is all working fine and well on a localhost set up.

我有一个域名,当前活动网站,当我上传这个新网站作为一个额外的页面,它仍然预先发送的电子邮件,但不会加载任何东西进入我的数据库。

I have a domain name with a current live website and when i upload this new website as an extra page it still preforms the sending of the email but won't load anything into my database.

我几乎可以肯定这是因为我的 php 电子邮件/数据库脚本指定 localhost 作为数据库连接,但如果我要将网页上传到我的活动域,我该如何连接它。

I'm almost certain it's because my php script for the email/database is specifying localhost as the DB connection but how do i go about connecting it if i was to upload the webpage to my live domain.

任何帮助:)

推荐答案


询问服务提供商的用户名和密码,然后导出sql文件并上传,然后请他们运行sql文件,然后尝试连接数据库。

Ask service provider for username and password and export sql file and upload then,ask them for run sql file and then try to connect database live.



<?php
$con = mysqli_connect("localhost","my_user","my_password","my_db");

// Check connection
if (mysqli_connect_errno())
  {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }
?>

这篇关于数据库连接到活动网站的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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