The Cache: Technology Expert's Forum
 
*
Welcome, Guest. Please login or register. September 22, 2019, 06:35:41 PM

Login with username, password and session length


Pages: [1]
  Print  
Author Topic: Help! This is driving me nuts.  (Read 3682 times)
vsloathe
vim ftw!
Global Moderator
Lifer
*****
Offline Offline

Posts: 1669



View Profile
« on: September 26, 2007, 05:51:23 PM »

Alright so I've got a table with 4 fields, looks like this
Code:
TABLE `unique` (
  `id` int(11) NOT NULL auto_increment,
  `ip` varchar(20) NOT NULL default '',
  `regid` varchar(50) NOT NULL default '',
  `num` int(11) NOT NULL default '0',
  PRIMARY KEY  (`id`)
)

Why the hell would the query

Code:
$query="INSERT INTO unique (ip, regid, num) VALUES ('$ip','$key','1')";

Not work? I have checked, and it will not work if I fill in the values manually either, so it has nothing to do with the variables, I confirmed they're both being properly set.
Logged

hai
vsloathe
vim ftw!
Global Moderator
Lifer
*****
Offline Offline

Posts: 1669



View Profile
« Reply #1 on: September 26, 2007, 06:02:37 PM »

Nevermind. Like an idiot I was using reserved words - in one table as the actual name, in another as a name of the attribute. I'm used to being pampered by MSSQL and flat out told I can't create a table with that name, lol.

 D'oh!
Logged

hai
arms
Expert
****
Offline Offline

Posts: 235



View Profile
« Reply #2 on: September 26, 2007, 06:35:02 PM »

also you don't need to quote the ints but i don't know if that causes an error.
Logged
nutballs
Administrator
Lifer
*****
Offline Offline

Posts: 5627


Back in my day we had 9 planets


View Profile
« Reply #3 on: September 26, 2007, 06:38:43 PM »

$query="INSERT INTO unique (ip, regid, num) VALUES ('$ip','$key','1')";

the bold part should not be quoted. the field is INT but you are passing a string it would seem. Unless oracle doesnt care.

But yea, the unique part seemed kinda like an odd table name.

To avoid the reserved names I always name my tables Application_Tablename
Also means that if you need to combine apps into 1 DB, you wont have problems.
Logged

I could eat a bowl of Alphabet Soup and shit a better argument than that.
vsloathe
vim ftw!
Global Moderator
Lifer
*****
Offline Offline

Posts: 1669



View Profile
« Reply #4 on: September 26, 2007, 07:50:40 PM »

Yeah I realized that soon after I posted, that I was putting the 1 in quotes. Thanks for pointing that out guys.

Finally got it to work correctly.
Logged

hai
Pages: [1]
  Print  
 
Jump to:  

Perkiset's Place Home   Best of The Cache   phpMyIDE: MySQL Stored Procedures, Functions & Triggers
Politics @ Perkiset's   Pinkhat's Perspective   
cache
mart
coder
programmers
ajax
php
javascript
Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks


Valid XHTML 1.0! Valid CSS!