I am struggling to link my PHPMyAdmin MySQL database to [duplicate]

310
July 05, 2017, at 00:22 AM

This question already has an answer here:

  • PHP Parse/Syntax Errors; and How to solve them? 11 answers

I am trying to link my MySQL database to my PHP code. My friend has the same code as me and is able to connect their database to their PHP code. I end up getting a error code and do not know where I am going wrong.

This is the code that I am using

<?php
$username="root";
$password="password";
$database="account";
$connect = mysql_connect('localhost', $username, $password);
//$db-select = mysql_select_db($database,$connect) or die("Unable to select database");
$user = $_GET['user'];
$pass = $_GET['pass'];
if(!$connect) {
    die('eror');
}
$db = my_sql_select_db("account", $connect)
mysql_query($db, "INSERT INTO 'account', 'tbl_account' (Username, Password) VALUES ('$user', '$pass')";);
mysql_close($connect);
?>

This is the outcome:

Parse error: syntax error, unexpected 'mysql_query' (T_STRING) in C:\Apache24\htdocs\PHP\index.php on line 11

Answer 1

add semicolon at the end of first line and remove the extra semicolon in second line

$db = my_sql_select_db("account", $connect);
mysql_query($db,"INSERT INTO 'account','tbl_account' (Username,Password) VALUES ('$user','$pass')");
Rent Charter Buses Company
READ ALSO
Warning shows when using SQLAlchemy with MySQL

Warning shows when using SQLAlchemy with MySQL

I'm using flask and SQLAlchemy to build my app, but I got some problem can't be fixedI setup my database in config

577
PHP + MySQL - What column type should be used to store serialized objects?

PHP + MySQL - What column type should be used to store serialized objects?

With PHP, I am storing serialized objects in a MySQL database

304
What&#39;s my best approach re: creating calculated tables based on scraped data

What's my best approach re: creating calculated tables based on scraped data

I have a few spiders running on my vps to scrape data each day and the data is stored in MySQL

149
Counting the same column with different where conditions [duplicate]

Counting the same column with different where conditions [duplicate]

This question already has an answer here:

212