Hi when let me get straight to the point .....

I've made a database, inserted data into it and selected it on a page but I can't find out why I can't view the text in the table?????????????? :@ I'M SO PISSED OFF!!!!!!!!!

I've been trying it for hours here's my code

//Code for forms data (it's kinda like a mock E-bay sight :))

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<title>Administrator's Page</title>
<link rel="stylesheet" href="style.php" type="text/css" />
<h1 align="center"> Welcome to the administrators page!</h1>
<h5 align="center">Add items to Inventory....</h5>
<hr />
<!-- LINKS START -->
<a href="Shauns_Room_Sale.php">Home</a> |
<a href="Browse.php">Browse Items</a>  |
<a href="Suggestions.php">Suggestions Toward Site</a> |
<a href="Order.php">Order an Item</a>
<a href="admin.php">Admin's Only</a>
<!-- LINKS END -->

<table border="0">
$week = date("l");

$Month_day_year = date("F, d, Y");
echo "<td>";
echo "<h3>Today is </h3> " . $week ." ". $Month_day_year;  
echo "</td>";
<form action="add.php" method="POST">
<legend>Items to add to database</legend>

 Item Name:  <input type="text" name="item" />
 <br />
Item Description: <input type="text" name="description" />
<br />
Item Price:<input type="text" name="price" />

<input type="Submit" value="Submit" /> <input type="Reset" value="Clear Fields" />
//now starts WHAT I CAN'T SEEM TO FIND OUT the server side scripting....
<a href="page_pass.php">Back to admin page</a>&nbsp; | &nbsp;<a href="Shauns_Room_Sale.php" >Home</a>

$con = mysql_connect("localhost", "root", "");

mysql_select_db("inventory_db", $con);

if (!$con)
  die('Could not connect: ' . mysql_error());

mysql_select_db("inventory_db", $con);

$sql="INSERT INTO item_inventory ()

if (!mysql_query($sql,$con))
  die('Error: ' . mysql_error());
echo "<h1 align='center'>1 record added</h1>";


I do apologize if I confuse someone but can anyone help?

...Oh yeah I'm using XXAMP and phpmyadmin if that helps finding the problem

Do I not know how to use phpmyadmin or something?

This line has a () that are probably killing the query

$sql="INSERT INTO item_inventory ()

BTW, doing raw POST inserts from users is asking for for trouble. See sql exploits...

I changed the "()" but nothing is shown in the table record ???

When I go to add the record in it adds it to the database in phpmyadmin but i can't view it in my web table ????????

The query syntax is incorrect. See MySql insert syntax on their site.

Member Avatar

If this code is all on one page - it's totally mashed - I don't know where to begin. You have html code below the html tag. You say the info has been added to the DB - but you seem to be sending form data to the same page for handling - not recommended, as your db add code will run when the form is simply displayed, not just sent.

To view the stored data in a html table/form fields, you need a SELECT query, which you don't seem to have.

If on the other hand, you can't insert data into a MySQL table - your SQL statement is a little mashed too.

$sql="INSERT INTO item_inventory ()

If you're going to do it like this, list your fields before 'VALUES' and sanitize your input:

$item = mysql_real_escape_string($_POST['item']);
$sql="INSERT INTO item_inventory (item, description,price) VALUES ('$item','$description','$price')";