General Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingGeneral Programming Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old March 28th, 2004, 07:09 AM
Pheifel Pheifel is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Location: Denmark
Posts: 174 Pheifel User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 43 m 46 sec
Reputation Power: 5
Send a message via MSN to Pheifel
Arrow Auto incriments

I need to be able to increase a variable with one, each time the specifik site is loadet. i have tried putting it into a database (db) each time logon accurs, and then fetch the db and then add '1' to the number, then save it again. But it dosn't work properly, it keep displaying 1 each time, and not increase it self.

Can enayone give an idear to hov this is done.

- Pheifel

Reply With Quote
  #2  
Old March 28th, 2004, 04:00 PM
tobycloud tobycloud is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Location: Near Albany NY
Posts: 27 tobycloud User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to tobycloud Send a message via AIM to tobycloud
Your idea will work. If it isn't the coding is bad somewhere. If you want, paste the code here.

Reply With Quote
  #3  
Old March 28th, 2004, 04:16 PM
Pheifel Pheifel is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Location: Denmark
Posts: 174 Pheifel User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 43 m 46 sec
Reputation Power: 5
Send a message via MSN to Pheifel
sure.... here goes

PHP Code:
//loads the id NB: ID is not autoincrease
    
$NYT mysql_query("SELECT * FROM USER_uploads WHERE userid = $USERID ORDER BY id DESC LIMIT 1");
    while (
$nyt mysql_fetch_array($NYT)) {
        
$ny $NYT[id] + 1;
        print 
"$ny<br>";
      
mysql_query(INSERT INTO (dbVALUES (bla... bla...)) 

but here, it doesnt print an increaing number, but keeps printing '1' and it doesnt insert into th db either. Thus never loading an creasing number.

Reply With Quote
  #4  
Old March 30th, 2004, 06:53 AM
crudesys crudesys is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Location: California
Posts: 25 crudesys User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
hi. try

$ny = $NYT['id'] + 1;

just a try

Reply With Quote
  #5  
Old March 30th, 2004, 08:14 AM
Pheifel Pheifel is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Location: Denmark
Posts: 174 Pheifel User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 43 m 46 sec
Reputation Power: 5
Send a message via MSN to Pheifel
i have tried that. And it gives the result of the new id as '1'... meaning, that it did not increase.

- Pheifel

Reply With Quote
  #6  
Old March 30th, 2004, 12:03 PM
crudesys crudesys is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Location: California
Posts: 25 crudesys User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
i think the statement $ny = $NYT[id] + 1;
is read as $ny = 0 + 1; which always results to 1, since there is nothing in $NYT[id]. use the actual field name 'userid' instead of 'id'

try a
$ny = $NYT[userid] + 1;
or
$ny = $NYT['userid'] + 1;

Reply With Quote
  #7  
Old March 30th, 2004, 05:32 PM
Pheifel Pheifel is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Location: Denmark
Posts: 174 Pheifel User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 43 m 46 sec
Reputation Power: 5
Send a message via MSN to Pheifel
here... i made it work this way :

[PHP] $NAME = mysql_fetch_array(mysql_query("SELECT * FROM USER_uploads WHERE userid = $USERID ORDER BY time DESC LIMIT 1"));
$navn = $NAME[id] + 1;

Reply With Quote
  #8  
Old March 30th, 2004, 06:02 PM
crudesys crudesys is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Location: California
Posts: 25 crudesys User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
great. i also made a mistake in my solution. supposed to be $nyt instead of $NYT

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingGeneral Programming Help > Auto incriments


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT