473,320 Members | 1,732 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Unable to see full result of mysql query in php

Hi folks.
I am just starting to dabble in php.

I am trying to do some simple pagination in php/mysql.

For whatever reason I am only getting the first digit of my result.

For example:

$result = mysql_query("select lamp_no from lamps as l where id=20");
$row = mysql_fetch_array($result);
echo "20 = " . $row[0]['l']

only displays 1 it should have displayed 15 for me.

Thanks,
Terry

Oct 9 '07 #1
3 1571
On Oct 9, 10:17 am, Terry <w...@rogers.comwrote:
Hi folks.
I am just starting to dabble in php.

I am trying to do some simple pagination in php/mysql.

For whatever reason I am only getting the first digit of my result.

For example:

$result = mysql_query("select lamp_no from lamps as l where id=20");
$row = mysql_fetch_array($result);
echo "20 = " . $row[0]['l']

only displays 1 it should have displayed 15 for me.

Thanks,
Terry
Not from the way your query looks. what happens if you run that exact
query in your mysql client?

what I would try is run the query:

"select lamp_no as l from lamps where id=20"

with my suggestion, l will be used for the column name instead of
lamp_no. From the looks of your query, your column name would still
be lamp_no instead of l.

Oct 9 '07 #2
On Oct 9, 4:04 pm, dkruger <davidkru...@techie.comwrote:
On Oct 9, 10:17 am, Terry <w...@rogers.comwrote:


Hi folks.
I am just starting to dabble in php.
I am trying to do some simple pagination in php/mysql.
For whatever reason I am only getting the first digit of my result.
For example:
$result = mysql_query("select lamp_no from lamps as l where id=20");
$row = mysql_fetch_array($result);
echo "20 = " . $row[0]['l']
only displays 1 it should have displayed 15 for me.
Thanks,
Terry

Not from the way your query looks. what happens if you run that exact
query in your mysql client?

what I would try is run the query:

"select lamp_no as l from lamps where id=20"

with my suggestion, l will be used for the column name instead of
lamp_no. From the looks of your query, your column name would still
be lamp_no instead of l.- Hide quoted text -

- Show quoted text -
One thing when working with arrays, if you are unsure what might be
going on with data not matching what you expect, I would try using the
command print_r(array) to display the contents of the array, and all
of the keys etc. This will usually give you an idea where a problem
might be occuring in your code.

Oct 9 '07 #3
Terry wrote:
Hi folks.
I am just starting to dabble in php.

I am trying to do some simple pagination in php/mysql.

For whatever reason I am only getting the first digit of my result.

For example:

$result = mysql_query("select lamp_no from lamps as l where id=20");
$row = mysql_fetch_array($result);
echo "20 = " . $row[0]['l']

only displays 1 it should have displayed 15 for me.

Thanks,
Terry
Yep. $row[0] is a string, containing the value of lamp_no. $row[0][1]
is a character in that string.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Oct 10 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: sammmista | last post by:
hello experts, Plz dont treat this as another newbie query , i did my homework but still getting nowhere :( :( :( Trying to learn PHP on Fedora core 1 (PHP 4.3,MySQL,HTTPD).Unable to post data...
2
by: Zeya | last post by:
I have an application where I am required to run a full text query. My database is MySQL and code in C#. The way all queries are SELECT * FROM table WHERE firstname = ? and using command...
4
by: UKuser | last post by:
Hi Guys, I am trying to create an editable table of a MySQL query where every field can be updated. My example script is at: http://nana46.coconia.net/test4.php however I am currently getting...
11
by: frizzle | last post by:
Hi groupies I'm building a news site, to wich a user can add new items into a mySQL db. It's still in testfase, but it's so extremely slow, i want to figure out what i'm doing wrong, or what to...
24
by: Phil Latio | last post by:
Let's say I have a simple web application running with just two MySQL tables. The tables structure is as follows: Table: category category_id (PK) category_name parent_category (FK)...
0
by: Buddy Home | last post by:
Hello, I'm trying to upload a file programatically and occasionally I get the following error message. Unable to write data to the transport connection: An established connection was aborted...
3
by: Buddy Home | last post by:
Hello, I'm trying to upload a file programatically and occasionally I get the following error message. Unable to write data to the transport connection: An established connection was aborted...
8
by: malaysiauser | last post by:
Im new user of PHP and MySQL. I tried to use a script package for my web. I'd created a database. And my connection scripts are as follow; <?php $mysql_host="localhost"; ...
1
by: matiruv | last post by:
k am using php and mysql in dreamweaver.the thing is my code seems k and when running my webpage it is saying my staff are successfully inserted in mysql db.mysql database table has 4 columns...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.