0

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

3
Contributors
4
Replies
6
Views
7 Years
Discussion Span
Last Post by mwasif
0

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

0

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());
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.