If you are viewing this in 2017, for your " connect_to_mysql.php" use the code below; <?php $con = mysqli_connect("localhost","username","password","database");
// Check connection if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } ?>
and for your create_admin_table.php, use the code below; <?php //connect to db
require"connect_to_mysql.php";
$sql = "CREATE TABLE admin ( id int(11) NOT NULL auto_increment, username varchar(255) NOT NULL, password varchar(255) NOT NULL, last_log_date date NOT NULL, PRIMARY KEY (id), UNIQUE KEY username (username) )";
if ($con->query($sql) === TRUE) { echo "Table created successfully"; } else { echo "Error creating table: " . $con->error; }
Hi guys.. I would like to ask you something. The connection to the db is fine but the table is not created.. Any ideas? Thank you and nice work bro ! ๐
Really helpful. I can get it to work with hosting on 1and1, but cannot get it to work on CrazyDomains. Cant even get index.php to come up. Any ideas? Thanks in advance.
Hi Adam, I am trying to create a web page, after adding div and floating them when am trying to resize the window all divs overlaps, could you please share a tutorial how to overcome that issue. Like your website when I resize they don't overlaps I can see they are fixed where they are when the window was maximum and when I resize it the divs don't overlaps and a scroll bar appears at the browser window.
you rock @Adam Khoury. I am all over this series (and prob others)- 6 YEARS LATER – and I know stuff changes but you are insane – love your style BOSS!
@Adam Khoury your videos are amazing. Not sure if you have any info or could make a video on setting this whole thing up on a AWS EC2 Ubuntu LAMP stack instead of going through Cpanel? Would love to learn out to do that.
Hi Adam Your Transaction Script For Paypal Do Not Contain Any Filed or Gathering Buyer's Phone Number From Paypal. As A part For Shipping Products Phone Number Is Really Essential Without Its In Complete.
Thank you so much for your tutorials Adam Khoury…been watching from part 1 and still continuing. GOD BLESS YOU! watching all the way from KENYA, Happy coding viewers :). Cant thank you enough for how much you've made me understand php ๐
25 responses to “2. E – Commerce Website PHP Tutorial – MySQL Database and its Tables”
can i use phpmyadmin as my database?
can i use Waamp?
This also may help:
<?php
echo "<html>
<head><title>Test MySQL</title></head>
<body>";
$host = "localhost";
$user = "root";
$password = "";
$cxn = mysqli_connect($host, $user, $password);
$sql = "SHOW DATABASES";
$result = mysqli_query($cxn, $sql);
if ($result == false) {
echo "<h4>Error: ".mysqli_error($cxn)."</h4>";
} else {
if (mysqli_num_rows($result) < 1) {
echo "<p>No current databases</p>";
} else {
echo "<ol>";
while ($row = mysqli_fetch_row($result)) {
echo "<li>$row[0]</li>";
}
echo "</ol>";
}
}
?>
</body></html>
If you are viewing this in 2017, for your " connect_to_mysql.php" use the code below;
<?php
$con = mysqli_connect("localhost","username","password","database");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
?>
and for your create_admin_table.php, use the code below;
<?php
//connect to db
require"connect_to_mysql.php";
$sql = "CREATE TABLE admin (
id int(11) NOT NULL auto_increment,
username varchar(255) NOT NULL,
password varchar(255) NOT NULL,
last_log_date date NOT NULL, PRIMARY KEY (id),
UNIQUE KEY username (username) )";
if ($con->query($sql) === TRUE) {
echo "Table created successfully";
} else {
echo "Error creating table: " . $con->error;
}
$con->close();
?>
IT WORKS PERFECTLY !!!
Do you have to pay to use cPanel?
anyone who can help me to design database for online store for different categories
hi can i get some help on how to add a user login. because i don't know how to connect it to the cart
what if i'm using xampp? The mysql_quicktest worked but the create admin table did not echo any message thus no table was made.
Hi guys.. I would like to ask you something. The connection to the db is fine but the table is not created.. Any ideas? Thank you and nice work bro ! ๐
Really helpful. I can get it to work with hosting on 1and1, but cannot get it to work on CrazyDomains. Cant even get index.php to come up. Any ideas? Thanks in advance.
Just Love your Work here. Thank you and Bless You
Fantastic! Any chance on updating the database connection??? ๐ PDO or MYSQLi
Hi Adam,
I am trying to create a web page, after adding div and floating them when am trying to resize the window all divs overlaps, could you please share a tutorial how to overcome that issue. Like your website when I resize they don't overlaps I can see they are fixed where they are when the window was maximum and when I resize it the divs don't overlaps and a scroll bar appears at the browser window.
you rock @Adam Khoury. I am all over this series (and prob others)- 6 YEARS LATER – and I know stuff changes but you are insane – love your style BOSS!
@Adam Khoury your videos are amazing. Not sure if you have any info or could make a video on setting this whole thing up on a AWS EC2 Ubuntu LAMP stack instead of going through Cpanel? Would love to learn out to do that.
THANK YOU SO MUCH!!!!
Hi Adam, this is such an incredible series you put together, PLEEAASSEE do an update!
do you have the update for mysqli tutorial instead of mysql. It seems to be deprecated for now.
Hii hello sir i needed help
what if the sql database i am using is not online just WAMP server phpmyadmin only?? whats the exact code please??
Hi Adam Your Transaction Script For Paypal Do Not Contain Any Filed or Gathering Buyer's Phone Number From Paypal. As A part For Shipping Products Phone Number Is Really Essential Without Its In Complete.
FileZilla says i'm successful but my storescripts/mysql_quicktest.php preview shows Not Found on this server.
Thank you so much for your tutorials Adam Khoury…been watching from part 1 and still continuing. GOD BLESS YOU! watching all the way from KENYA, Happy coding viewers :). Cant thank you enough for how much you've made me understand php ๐
What is this 'Flash Building, Take Flight With Us' in the beginning? what is this shit?
Thank you men, this is ground breaking