Database Connection to live site

北战南征 提交于 2019-12-14 03:59:10

问题


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.

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.

Any help is appreciated :)


回答1:


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();
  }
?>


来源:https://stackoverflow.com/questions/29592367/database-connection-to-live-site

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!