How to connect and create database at x10hosting?Please I need your suggestions and comments for my thesis project...Thanks!
How to connect and create database at x10hosting?Please I need your suggestions and comments for my thesis project...Thanks!
To create the database, see: http://x10hosting.com/wiki/How_to_Cr...abase_and_User
In your script, use the information you selected when creating the database to connect to the database. The hostname is localhost.
Best regards,
Brian Yang - TechAirlines
How am I doing? Click thestar button at the bottom left to rate this post. Thanks.
Terms of Service | Account Portal | Wiki
thats basically it, to connect to the database..<?
$host="localhost"; // Host name
$username=""; // Mysql username
$password=""; // Mysql password
$db_name=""; // Database name
//Connect to server and select database.
mysql_connect("$host", "$username", "$password")or die("cannot connect to server");
mysql_select_db("$db_name")or die("cannot select DB");
?>![]()
mysql_connect("$host", "$username", "$password")orwill this echo "cannot connect to server" "die("cannot connect to server");
█ BCV | Community Support Representative
█ x10Hosting - Giving Away Hosting Since 2004
█ Premium Hosting | VPS Services
the mysql_connect function connects to the server, mysql_select_db chooses the database and the die("cannot connect to server"); says that if there's an error connecting then it will display the message "cannot connect to server".
Thanks, Chris![]()
My way of doing it (that's what she said):
Put this in the page where you want to query, ex. index.php:Then put this in mysqlconnect.php and change it to 644 permissions (thanks rajat44)PHP Code:<?php require_once('mysqlconnect.php'); ?>
<?php mysql_select_db("your_db", $mysql);
$mysql_query = sprintf("SQL SYNTAX HERE");
$mysql_queried = mysql_query($mysql_query,$mysql) or die(mysql_error());
?>This way, the user/pass is only readable by the server. Also, you can use the "require_once" for every page, instead of copying user and pass to every page. Also, it's site-wide so when you change the MySQL server, you can change 1 file, and it's site-wide.PHP Code:<?php
$host="localhost"; // Host name
$username=""; // Mysql username
$password=""; // Mysql password
//Connect to server and select database.
$mysql = mysql_connect($host, $username, $password)or die("cannot connect to server");
?>
Hope this helps,
Josh