![]() |
![]() |
![]() |
||||
Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact us. |
![]() ![]() |
|
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed. |
|
Thread Tools |
![]() |
#1 |
Confirmed User
Industry Role:
Join Date: Nov 2003
Location: Toronto
Posts: 4,001
|
Quick PHP Question
I am using the following:
[CODE]$sqlquery = "UPDATE `table` SET `name` = '$name' WHERE `id` = 'id1'"; $results = mysql_query($sqlquery);/CODE] However, this only seems to be working for the ID that is 4 numerical characters long and not the ID that is 20 characters long with both numerical and alphabetical characters . Anyway to make this work with both? |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#2 |
Confirmed User
Industry Role:
Join Date: May 2005
Location: EU - Czech republic
Posts: 3,025
|
Use quotes exactly:
$name = name $id = id of row in table $sqlquery = "UPDATE `table` SET `name` = '".$name."' WHERE `id` = '".$id."'"; What data types do You have in Your sql table? |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#3 |
Confirmed User
Industry Role:
Join Date: May 2005
Location: EU - Czech republic
Posts: 3,025
|
and Yes, If You want to work with 20chars id's check atrib ID datatypes:
varchar (20) for alphabetical int (20) for numeric only |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#4 |
Confirmed User
Industry Role:
Join Date: Nov 2003
Location: Toronto
Posts: 4,001
|
ID = VARCHAR 20. It is also the Key. The script already pulls the ID from the url and when I echo ID1 on the page its correct
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#5 |
Confirmed User
Industry Role:
Join Date: Nov 2003
Location: Toronto
Posts: 4,001
|
Sorry - SET `name` = '55' name is already set in the script itself
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#6 |
Confirmed User
Industry Role:
Join Date: Nov 2003
Location: Toronto
Posts: 4,001
|
varchar (20) for alphabetical
int (20) for numeric only What should I use for both? It looks something like this 907fasd90f78aha |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#7 | |
Confirmed User
Join Date: Jul 2004
Location: SW Florida
Posts: 916
|
Quote:
__________________
ICQ: 148.167.599 |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#8 |
Confirmed User
Industry Role:
Join Date: Nov 2003
Location: Toronto
Posts: 4,001
|
still not working. sorry for the newb question but does anyone know how to just insert an increasing number into the ID table instead? Starting at 1. so each time a new entry is inserted, a new increasing id is created, 1, 2, 3 ., etc. I cant find my php for dummies book
![]() |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#9 |
Confirmed User
Join Date: Dec 2004
Location: NL (Eindhoven), CZ(Prague), FR(Concarneau)
Posts: 3,958
|
in phpmyadmin next to the attribute tick the auto_increment
__________________
[img]http://****************/sig/fhv3_j2_624x80_2.gif[/img] $35-40 Per Signup, 60-70% Rev Share, over 80 Sites, Exclusive Sites, tons of free content 14,000+ Free hosted Galleries, RSS feeds, Domain Hosting, Embedded Flash Movies Join Fetish Hits now! ICQ: 358652230 |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#10 |
Confirmed User
Join Date: Dec 2004
Location: NL (Eindhoven), CZ(Prague), FR(Concarneau)
Posts: 3,958
|
or just put auto_increment in your sql
__________________
[img]http://****************/sig/fhv3_j2_624x80_2.gif[/img] $35-40 Per Signup, 60-70% Rev Share, over 80 Sites, Exclusive Sites, tons of free content 14,000+ Free hosted Galleries, RSS feeds, Domain Hosting, Embedded Flash Movies Join Fetish Hits now! ICQ: 358652230 |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#11 |
Confirmed User
Industry Role:
Join Date: Nov 2003
Location: Toronto
Posts: 4,001
|
Ok thanks, so how would I retype this line:
$sqlquery = "INSERT INTO $table VALUES('$txn_id','next........ Where I want to replace $txn_id with an auto increment number |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#12 |
Confirmed User
Join Date: Oct 2002
Posts: 823
|
Just omit the autoincrement field from your query, it will be generated automatically when you insert other fields.
Use mysql_insert_id() to obtain the value of that field right after the insert query, if you need it...
__________________
Adult Niche Traffic Exchange |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#13 |
Confirmed User
Industry Role:
Join Date: Nov 2003
Location: Toronto
Posts: 4,001
|
Got it working, thanks!
|
![]() |
![]() ![]() ![]() ![]() ![]() |