[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Warning: SQL cant jump to...

Posted on 2006-11-04
8
Medium Priority
?
235 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 1000 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
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.
Suggested Courses

650 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