Solved

Warning: SQL cant jump to...

Posted on 2006-11-04
8
214 Views
Last Modified: 2006-11-18
is this warning a big deal?

ive been writting a few things where i have it jump directly to row 0...

is that bad?

example: $ownerscreenname = mysql_result($sql_blogcommentsn,0,"users.username");


better approach?
0
Comment
Question by:n8dog
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
8 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 250 total points
ID: 17874094
usually, msql_result is not recommended, as it is slower than the other methods...

so, what are you trying to do in general?

usually, you loop with mysql_fetch_assoc() on the resultset, and have hence the results in a nice array:
http://php.net/manual/function.mysql-fetch-assoc.php

if ($sql_blogcommentsn = mysql_query($sql))
{
   while ( $row = mysql_fetch_assoc($sql_blogcommentsn))
   {
       $ownerscreenname = $row["username"];
   }
}

note that you don't specify the table name of the column when you access the field. if you have the same fieldname when joining multiple tables, you have to give them alias names in the query so they can be distiguished later...
0
 

Author Comment

by:n8dog
ID: 17874104

jeez, i use that manner of accessing all of my database stuff... and the site im working on its 100% db based..

woops!


what level of speed difference are we talking about here?
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 17874131
well, I never tried it, as I avoided that function from the beginning on...
the gains should be subsecond usually, so only be important when the page would suffer from heavy traffic.
now, mysql_result can of course be used, for example when you have queries like "select count(*) from ... " where indeed you only need to fetch a single row/column.

to come back to the actual "warning". it should not be ignored, because probably it means you have an issue.
it could be that the query returned no rows at all, or you are trying to run the function several times at once in 1 line of code ,
0
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 

Author Comment

by:n8dog
ID: 17874338

well for instance when im looking up a particular record, just indentify it directly, knowing that i will only get 1 row back..

so then i use $ownerscreenname = mysql_result($sql_blogcommentsn, 0 ,"users.username");  // NOTE: the 0 in place $counter
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 17874352
if ($sql_blogcommentsn = mysql_query($sql))
{
   if ( $row = mysql_fetch_assoc($sql_blogcommentsn))
   {
       $ownerscreenname = $row["username"];
   }
}

now again:
* dont use the table name when getting the field value!
* are you sure that there is 1 row all the time?
0
 

Author Comment

by:n8dog
ID: 17874510


well, i should probably upgrade my method of working with it then, yes?

my errorlogs are filled with TONS of warnings regarding this.. with my users using the blogs, forums, etc.. they get hit pretty often. thus creating this..

although i guess i could turn off warnings too...

0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 17875683
>although i guess i could turn off warnings too...
that's of course the lazy method... just hiding all the potential other issues...
0
 

Author Comment

by:n8dog
ID: 17875695
you're 100% correct.. i wanted to feel lazy for a moment.. ok, the moment is over :)

-n

0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
e commerce steps shown instead of self testing 2 56
Google Recaptcha 13 51
How can I send attachment with mail 5 24
Last 4 numbers of a variable 9 20
Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question