Hi
I want to know that how to connect a HTML code to the SQL using PHP. I have just created a form in HTML but I don't know how to connect it with the SQL of local server. So please help me.
Thanks in advance.
| SitePoint Sponsor |
Hi
I want to know that how to connect a HTML code to the SQL using PHP. I have just created a form in HTML but I don't know how to connect it with the SQL of local server. So please help me.
Thanks in advance.

As you haven't mentioned which database exactly you are using, I will suggest using PDO, which covers most of the common databases.


I am using Xampp Server for the PHP. So I want to connet to database of this server.


Okay, you will need to know your username and password for your MySQL setup (it likely asked you this during installation)
To Connect: http://www.php.net/manual/en/pdo.construct.php
To Run a Query: http://www.php.net/manual/en/pdo.prepare.php


@sid8 ;
If you'd like a tutorial approach, check out the latest postings from PHP Master: http://phpmaster.com/avoid-the-origi...l-extension-2/
You would connect as follows:
mysql_connect(servername,username,password);
Hope this helps.
___________________________________________________________________
ProntoScreen.com - Criminal Background Check
ContactLensBrands.com - Compare Contact Lenses
CriminalBase.com - Instant Background Check


thanks for the help frnds..I have done with it..
Hello,
You would connect as follows:
In PHP, this is done with the mysqli_connect() function.
This is the syntax for MySQL connect through php
PHP Code:<?php
// Create connection
$con=mysqli_connect("example.com","peter","abc123","my_db");
// Check connection
if (mysqli_connect_errno($con))
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
?>
Last edited by cpradio; Feb 26, 2013 at 04:49. Reason: Added [php] tags
Bookmarks