Webmaster Forum


Go Back   Webmaster Forum > Web Development > Web Design Lobby > Coding Forum
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Coding Forum Problems with your code? Let's hear about it.

   

Reply
 
LinkBack Thread Tools Display Modes
Old 09-21-2004, 10:29 PM   #1 (permalink)
v7n Mentor
 
Sketch's Avatar
 
Join Date: 05-06-04
Location: London, UK
Posts: 1,453
iTrader: 0 / 0%
Latest Blog:
None

Sketch is a highly respected web proSketch is a highly respected web proSketch is a highly respected web proSketch is a highly respected web proSketch is a highly respected web proSketch is a highly respected web proSketch is a highly respected web proSketch is a highly respected web proSketch is a highly respected web proSketch is a highly respected web proSketch is a highly respected web pro
SQL - Insert values

Ok. Here is my script

$dbuser="<USERNAME>";
$dbpass="<PASSWORD>";
$dbname="phone"; //the name of the database
$chandle = mysql_connect("localhost", $dbuser, $dbpass)

or die("Connection Failure to Database");

mysql_select_db($dbname, $chandle) or die ($dbname . " Database not found. " . $dbuser);

$query="INSERT INTO FILE (A_ID, A_PHONE, A_PRICE, A_CAT, A_IMAGE, A_NAME, A_INFO) VALUES ('A0004','Nokia','38','Accessories','image/item/A0003.gif','Nokia Phone','Information')";

mysql_db_query($dbname, $query) or die("Failed Query of " . $query);



FILE is the table that I am trying to put the data into.

Within FILE there are "A_ID, A_PHONE, A_PRICE, A_CAT, A_IMAGE, A_NAME, A_INFO" Columns, no more no less. But still every time I run this page I get the error.

What have done wrong??


Thanks in advance
Sketch is offline  
Add Post to del.icio.us
Reply With Quote
Old 09-21-2004, 11:41 PM   #2 (permalink)
Inactive
 
littleFella's Avatar
 
Join Date: 06-20-04
Location: Ontario
Posts: 3,359
iTrader: 0 / 0%
Latest Blog:
None

littleFella is a splendid one to beholdlittleFella is a splendid one to beholdlittleFella is a splendid one to beholdlittleFella is a splendid one to beholdlittleFella is a splendid one to beholdlittleFella is a splendid one to beholdlittleFella is a splendid one to beholdlittleFella is a splendid one to beholdlittleFella is a splendid one to beholdlittleFella is a splendid one to beholdlittleFella is a splendid one to behold
did you make sure that:

are data types ok?
does the user have privileges to insert records?
is the table locked by another process?

btw. what does the error say?
littleFella is offline  
Add Post to del.icio.us
Reply With Quote
Old 09-22-2004, 12:14 AM   #3 (permalink)
v7n Mentor
 
Sketch's Avatar
 
Join Date: 05-06-04
Location: London, UK
Posts: 1,453
iTrader: 0 / 0%
Latest Blog:
None

Sketch is a highly respected web proSketch is a highly respected web proSketch is a highly respected web proSketch is a highly respected web proSketch is a highly respected web proSketch is a highly respected web proSketch is a highly respected web proSketch is a highly respected web proSketch is a highly respected web proSketch is a highly respected web proSketch is a highly respected web pro
The 'die("Failed Query of " . $query);' thing that trows up the error just says Failed Query of (CODE)

And yer. The data types are Ok. there shouldn't be a problem with that. And the user does have access...

But when you say the table is locked by antoher process? What does that mean? Why would it be locked?
Sketch is offline  
Add Post to del.icio.us
Reply With Quote
Old 09-22-2004, 12:37 AM   #4 (permalink)
Inactive
 
littleFella's Avatar
 
Join Date: 06-20-04
Location: Ontario
Posts: 3,359
iTrader: 0 / 0%
Latest Blog:
None

littleFella is a splendid one to beholdlittleFella is a splendid one to beholdlittleFella is a splendid one to beholdlittleFella is a splendid one to beholdlittleFella is a splendid one to beholdlittleFella is a splendid one to beholdlittleFella is a splendid one to beholdlittleFella is a splendid one to beholdlittleFella is a splendid one to beholdlittleFella is a splendid one to beholdlittleFella is a splendid one to behold
depending on the version of MySQL there may be a table level lock in effect. In short, a table may be locked if there is already an insert/update/delete/select running against that table. The lock is usually in effect untill a transaction is completed, or the UNLOCK command is issued. If you designed the table and have full control over it then I assume you do not have any locks on the table. Otherwise you would not be asking about what locking is. I also assume that MySQL does't use automatic locking.

In addition to the above, I have no clue what your problem may be

How about trying this:

"INSERT INTO FILE VALUES ('A0004','Nokia','38','Accessories','image/item/A0003.gif','Nokia Phone','Information')";

Notice no field names.
This should work if the number of values is exactly the same as the number of fields in the table, and if the datatypes of fields coincide with respective fieldds data types

Also, debugging the SQL on the command line level, as opposed to wrapping SQL in PHP, may help you better diagnose the reason of the failure.
littleFella is offline  
Add Post to del.icio.us
Reply With Quote
Old 09-22-2004, 02:47 AM   #5 (permalink)
v7n Mentor
 
Sketch's Avatar
 
Join Date: 05-06-04
Location: London, UK
Posts: 1,453
iTrader: 0 / 0%
Latest Blog:
None

Sketch is a highly respected web proSketch is a highly respected web proSketch is a highly respected web proSketch is a highly respected web proSketch is a highly respected web proSketch is a highly respected web proSketch is a highly respected web proSketch is a highly respected web proSketch is a highly respected web proSketch is a highly respected web proSketch is a highly respected web pro
Found the problem. I put into the code mysql_error() so it would tell me my problem. I had problem with my Primary Key, I kinda was trying to make 2 things under the same Key :s

So sorry, that was stupid.

:s

Last edited by Sketch : 09-22-2004 at 02:58 AM.
Sketch is offline  
Add Post to del.icio.us
Reply With Quote
Go Back   Webmaster Forum > Web Development > Web Design Lobby > Coding Forum

Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Passing PR Values on SAME URL allreal Marketing Forum 4 02-23-2007 07:34 AM
up6.org and up8.org - Values? Nick Domain Name Forum 4 02-14-2006 05:00 PM
Domain Values John Scott Domain Name Forum 7 07-12-2004 07:00 PM


Sponsor Links
Get exposure! Get exposure! Find Scripts Web Hosting Directory Get exposure! SEO Blog


All times are GMT -7. The time now is 02:58 AM.
© Copyright 2008 V7 Inc