Connect to MySQL

6 posts Page 1 of 1
Contributors
User avatar
Insignia
VIP-Member
VIP-Member
Posts: 238
Joined: Thu Feb 11, 2010 5:15 pm

Connect to MySQL
Insignia
The PHP way of connecting to MySQL.
Code: Select all
<?php
$db = mysql_connect("mysql server", "username", "password")
or die("Cannot connect to: " . mysql_error());
echo "Succesfully connected to the MySQL Database";
mysql_close($db);
?>
Have Fun :D
User avatar
rocky4126
VIP - Donator
VIP - Donator
Posts: 258
Joined: Mon Nov 16, 2009 7:39 pm

Re: Connect to MySQL
rocky4126
I'd use a PDO connection. More secure. Just my advice
Image
User avatar
Scottie1972
Codenstuff Elite
Codenstuff Elite
Posts: 953
Joined: Thu Jan 14, 2010 5:48 am

Re: Connect to MySQL
Scottie1972
I like to use MySQL.Connector.NET
LINK: http://www.mysql.com/downloads/connector/net/

It is very easy to use, and there is all sorts of example code snippets all over the internet and a few nice snippets at the Snippet Library.

Snippet Library
LINK: http://dlh-digital.com/Snippet/Welcome.php
Image
User avatar
mandai
Coding God
Coding God
Posts: 2585
Joined: Mon Apr 26, 2010 6:51 pm

Re: Connect to MySQL
mandai
How is PDO more secure?
Last edited by mandai on Thu May 10, 2012 6:29 pm, edited 1 time in total.
User avatar
IxPr0GrAm
New Member
New Member
Posts: 11
Joined: Wed Jun 08, 2011 11:34 pm

Re: Connect to MySQL
IxPr0GrAm
The easiest way for me is just ftp and filezilla to also make forums with phpbb there is site that already got mysql built in and you can just make one for w/e the site is: Byethost.com
User avatar
daniz
Just Registered
Just Registered
Posts: 4
Joined: Fri Nov 26, 2010 8:03 pm

Re: Connect to MySQL
daniz
Insignia wrote:
The PHP way of connecting to MySQL.
Code: Select all
<?php
$db = mysql_connect("mysql server", "username", "password")
or die("Cannot connect to: " . mysql_error());
echo "Succesfully connected to the MySQL Database";
mysql_close($db);
?>
Have Fun :D
Try with: $db = mysql_connect("mysql server", "databasename", "username", "password")
mandai wrote:
How is PDO more secure than the MySQL connector?
PDO prevents MySQL Injections with the prepared statements and its faster with the queryes!!
6 posts Page 1 of 1
Return to “Tutorials”