Hi all...

Im having some trouble inserting values to my mySQL database.
I have the following installed on my local system.

MySQL
Server: localhost via TCP/IP
Server version: 5.1.43-community
Protocol version: 10
User: root@localhost
MySQL charset: UTF-8 Unicode (utf8)
Web server
Apache/2.2.14 (Win32) PHP/5.2.12
MySQL client version: 5.0.51a
PHP extension: mysql
phpMyAdmin
Version information: 3.2.5

COMPUTER

Windows 7 Home Premium

System
--------------------------------------------------------------------------------

Manufacturer Hewlett-Packard
Model HP Pavilion dv6 Notebook PC
Total amount of system memory 4.00 GB RAM
System type 64-bit operating system
Number of processor cores 2

Storage
--------------------------------------------------------------------------------

Total size of hard disk(s) 466 GB
Disk partition (C:) 388 GB Free (452 GB Total)
Disk partition (D:) 2 GB Free (13 GB Total)
Disk partition (E:) 92 MB Free (99 MB Total)
Media drive (F:) CD/DVD

Graphics
--------------------------------------------------------------------------------

Display adapter type Intel(R) Graphics Media Accelerator HD
Total available graphics memory 1696 MB
Dedicated graphics memory 32 MB
Dedicated system memory 32 MB
Shared system memory 1632 MB
Display adapter driver version 8.15.10.1968
Primary monitor resolution 1366x768
Secondary monitor resolution 1280x1024
DirectX version DirectX 10

Network
--------------------------------------------------------------------------------

Network Adapter Intel(R) WiFi Link 1000 BGN

I can connect to the database fine.
I can select data and display it on any page with no problems.
I can even update an entry in the database from php.
I can insert, update, delete, and do any normal function from phpMyAdmin.

The problem comes when I try to insert a new set of values in a table that exists using PHP.

This is the code im using.

<?php
$con = mysql_connect("localhost","username","pass");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("thisismydb", $con);

mysql_query("INSERT INTO news (date, title, suredel) VALUES ('2010-02-12','test','89339')");

mysql_close($con);
?>

Again.. I want to stress the fact that I can use the exact same info above to view and update data in the database.

The above code works fine if I use it on my hosted .com

Ive tried to come at this thing from every direction I can think of with no luck..

any help would be very appreciated.

Thanks so much,
LTT

Hi,
My suggestion is simple and may u feel silly too.But just try it .

mysql_query("INSERT INTO news (date, title, suredel) VALUES ('2010-02-12','test','89339')",$con);


Thank you,
prem2

Nope... that didnt solve it..

Use mysql_error() to identify the error in the following way.

mysql_query("INSERT INTO news (date, title, suredel) VALUES ('2010-02-12','test','89339')") or die ("Error in query. Error: ".mysql_error());

Duplicate

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.