GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   Quick PHP Question (https://gfy.com/showthread.php?t=554505)

mkx 12-20-2005 04:47 AM

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?

ilbb 12-20-2005 04:52 AM

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?

ilbb 12-20-2005 04:53 AM

and Yes, If You want to work with 20chars id's check atrib ID datatypes:

varchar (20) for alphabetical
int (20) for numeric only

mkx 12-20-2005 04:56 AM

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

mkx 12-20-2005 04:58 AM

Sorry - SET `name` = '55' name is already set in the script itself

mkx 12-20-2005 05:05 AM

varchar (20) for alphabetical
int (20) for numeric only

What should I use for both? It looks something like this 907fasd90f78aha

GFX Wiz 12-20-2005 06:16 AM

Quote:

Originally Posted by mkx
varchar (20) for alphabetical
int (20) for numeric only

What should I use for both? It looks something like this 907fasd90f78aha

char (20)

mkx 12-20-2005 03:06 PM

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 :pimp

Sam Granger 12-20-2005 03:10 PM

in phpmyadmin next to the attribute tick the auto_increment

Sam Granger 12-20-2005 03:11 PM

or just put auto_increment in your sql

mkx 12-20-2005 03:31 PM

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

Phoenix66 12-20-2005 04:30 PM

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...

mkx 12-21-2005 05:29 AM

Got it working, thanks!


All times are GMT -7. The time now is 04:32 AM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123