Jump to content

[SOLVED] Beginner Help.


tj71587

Recommended Posts

Hey all I just installed php and mysql on a cent os box.  I am able to get phpinfo() to display, therefore I am sure it installed.  I am just trying to insert things into the data base using this code:  (I have a database named test and a table named tracker with the fields username and password)

<html>
<head>
<title>DBASE</title>
</head>
<body>
<?php
include 'includes/config.php';
include 'includes/opendb.php';

mysql_select_db($mysql);
$query = "INSERT INTO test ( tracker.username, tracker.password) VALUES ('TEST', 'TEST')";

mysql_query($query) or die('Error, insert query failed First One');

$query = "FLUSH PRIVILEGES";
mysql_query($query) or die('Error, insert query failed');

include 'includes/closedb.php';
?>
</body>
</html>

 

Here are the includes I have:

 

config.php:

<?php
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = 'password';
$dbname = 'test';
?>

opendb.php:

<?php
// This is an example opendb.php
$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die                      ('Error connecting to mysql');
mysql_select_db($dbname);
?>

closedb.php:

<?php
// an example of closedb.php
// it does nothing but closing
// a mysql database connection

mysql_close($conn);
?>

I get this error message: Error, insert query failed First One

 

Is it a php setting or mysql setting or is my syntax just wrong.

 

thanks.

Link to comment
https://forums.phpfreaks.com/topic/67974-solved-beginner-help/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.