![]() |
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? |
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? |
and Yes, If You want to work with 20chars id's check atrib ID datatypes:
varchar (20) for alphabetical int (20) for numeric only |
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
|
Sorry - SET `name` = '55' name is already set in the script itself
|
varchar (20) for alphabetical
int (20) for numeric only What should I use for both? It looks something like this 907fasd90f78aha |
Quote:
|
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
|
in phpmyadmin next to the attribute tick the auto_increment
|
or just put auto_increment in your sql
|
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 |
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... |
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