Trying to write a php script where the user will enter the row number
(index) of a record. Say, for example, user wants record 55:
[MySQL]: select * from MyTable where Index = "55"
where Index is an autoincrement value, and also an index.
Unfortunately, MySQL barfs on this type of instruction. Doesn't seem
to want to let me access Index values...
Any suggestions?
Thanks,
Mike Darrett 7 2098 mi*********@darrettenterprises.com wrote: Trying to write a php script where the user will enter the row number (index) of a record. Say, for example, user wants record 55:
[MySQL]: select * from MyTable where Index = "55"
where Index is an autoincrement value, and also an index.
Unfortunately, MySQL barfs on this type of instruction. Doesn't seem to want to let me access Index values...
Any suggestions?
Index is a reserved word so you are better not to call your column
"Index". If you don't want to change the column name (although you
really should) then you need to add backticks around the column name
like so:
select * from MyTable where `Index` = "55"
--
Chris Hope - The Electric Toolbox - http://www.electrictoolbox.com/ mi*********@darrettenterprises.com wrote: Trying to write a php script where the user will enter the row number (index) of a record. Say, for example, user wants record 55:
[MySQL]: select * from MyTable where Index = "55"
where Index is an autoincrement value, and also an index.
Unfortunately, MySQL barfs on this type of instruction. Doesn't seem to want to let me access Index values...
Any suggestions?
Thanks,
Mike Darrett
Mike,
If you have a column named Index it is probably a reserved word
problem that will go away if you rename the column.
HTH
>Trying to write a php script where the user will enter the row number (index) of a record. Say, for example, user wants record 55:
[MySQL]: select * from MyTable where Index = "55"
where Index is an autoincrement value, and also an index.
Unfortunately, MySQL barfs on this type of instruction. Doesn't seem to want to let me access Index values...
Any suggestions?
Pick a column name that isn't a reserved word, or quote the
column name (with backquotes). This also applies to table
names especially if you insist on naming it `table`.
select * from `MyTable` where `Index` = "55";
For further examples look at the output of SHOW CREATE TABLE.
Gordon L. Burditt
mike-nos...@darrettenterprises.com wrote: Trying to write a php script where the user will enter the row number (index) of a record. Say, for example, user wants record 55:
[MySQL]: select * from MyTable where Index = "55"
where Index is an autoincrement value, and also an index.
Unfortunately, MySQL barfs on this type of instruction.
It is usually a sood idea to quote the exact error message.
"Barf" is very colorful, but unfortunately not technical
enough to see where the problem might be coming from...
Any suggestions?
Get rid of double quotes. In MySQL, numerical values
can be passed without enclosing, string values are
enclosed with single quotes. Also, 'INDEX' is a reserved
word in MySQL, so you should put in into backticks if
you have a field with that name. This should work:
SELECT * FROM MyTable WHERE `Index` = 55
Cheers,
NC
Chris Hope wrote: mi*********@darrettenterprises.com wrote:
Trying to write a php script where the user will enter the row
number (index) of a record. Say, for example, user wants record 55:
[MySQL]: select * from MyTable where Index = "55"
where Index is an autoincrement value, and also an index.
Unfortunately, MySQL barfs on this type of instruction. Doesn't
seem to want to let me access Index values...
Any suggestions?
Index is a reserved word so you are better not to call your column "Index". If you don't want to change the column name (although you really should) then you need to add backticks around the column name like so:
select * from MyTable where `Index` = "55"
-- Chris Hope - The Electric Toolbox - http://www.electrictoolbox.com/
Great! Thanks guys. Never would have guessed that it's a reserved
word, since MySQL allowed me to create the column... backticks work
great in this case.
Mike
.oO(Chris Hope) Index is a reserved word so you are better not to call your column "Index". If you don't want to change the column name (although you really should) then you need to add backticks around the column name like so:
select * from MyTable where `Index` = "55"
Don't quote numeric values.
Don't use SELECT * .
Micha mi*********@darrettenterprises.com wrote: Trying to write a php script where the user will enter the row number (index) of a record. Say, for example, user wants record 55:
[MySQL]: select * from MyTable where Index = "55"
where Index is an autoincrement value, and also an index.
Unfortunately, MySQL barfs on this type of instruction. Doesn't seem to want to let me access Index values...
Any suggestions?
Thanks,
Mike Darrett
If Index is a primary key you can use _rowid in SELECT statements to
reference it.
Lewis Shadoff This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: TheKeith |
last post by:
I'm just learning php and set up a sample mysql db to practice with. I
have the following script and cannot for the life of me figure out why
it is printing each field of the row twice? I checked...
|
by: dev |
last post by:
how create a temp table as a copy of a existing table and then update1 field
and insert the hole temp table back in the existing table?
please any help?
if i have 10 fields in 1 record and...
|
by: Bob Bedford |
last post by:
Does exist a next prev function in PHP/Mysql. I've a website with returns
lot of records (say about 200). The user may browse trough the list or
returned records, but he has to click the record...
|
by: grumfish |
last post by:
I'm trying to add a row to a MySQL table using insert. Here is the code:
connection = MySQLdb.connect(host="localhost", user="root", passwd="pw",
db="japanese")
cursor = connection.cursor()...
|
by: Shashikant Kore |
last post by:
Hi,
I am using MySQL for a table which will have 100M+ records, avg length
of records being 130 bytes.
When the number of records reach approx. 25M (and the file size close
to 4GB), the rate of...
|
by: William Gill |
last post by:
I have been trying to pass parameters as indicated in the api.
when I use:
sql= 'select * from %s where cusid = %s ' % name,recID)
Cursor.execute(sql)
it works fine, but when I try :
sql=...
|
by: moller |
last post by:
Im looking in to the possibility of moving from mySQL to
an access database.
My reasons are:
(1) Database is single user.
(2) Database local on users PC.
(3) Database has only 8 tables where 4...
|
by: laredotornado |
last post by:
Hi,
I have two columns, both MySQL 4 DATETIME types ...
TABLE1.depart_day
TABLE2.depart_day
and both are indexed. The problem is, all of TABLE1's dates have a
time of midnight (e.g....
|
by: NancyJ |
last post by:
Currently we have a database with a main table containing 3 million
records - we want to increase that to 10 million but thats not a
possibility at the moment.
Nearly all 3 million records are...
|
by: lllomh |
last post by:
Define the method first
this.state = {
buttonBackgroundColor: 'green',
isBlinking: false, // A new status is added to identify whether the button is blinking or not
}
autoStart=()=>{
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM)
The start time is equivalent to 19:00 (7PM) in Central...
|
by: Aliciasmith |
last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
|
by: tracyyun |
last post by:
Hello everyone,
I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
|
by: giovanniandrean |
last post by:
The energy model is structured as follows and uses excel sheets to give input data:
1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
|
by: NeoPa |
last post by:
Introduction
For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
|
by: nia12 |
last post by:
Hi there,
I am very new to Access so apologies if any of this is obvious/not clear.
I am creating a data collection tool for health care employees to complete. It consists of a number of...
|
by: NeoPa |
last post by:
Introduction
For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
|
by: isladogs |
last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, Mike...
| |