Resource ID
am 19.10.2007 12:02:04 von KyeCan anybody please suggest to me where I can look up what a Resource id #71
is??? No success so far looking for what the resource codes are on the net.
--
Yours Sincerely
Kye
Can anybody please suggest to me where I can look up what a Resource id #71
is??? No success so far looking for what the resource codes are on the net.
--
Yours Sincerely
Kye
> Can anybody please suggest to me where I can look up what a Resource id #71
> is??? No success so far looking for what the resource codes are on the net.
>
As far as I know, that is the 71st resource you create in your script.
There are functions for getting the type of the resource if you don't
know it. A resource is a PHP-special data type and is used for files,
database connections and a lot more. I don't think you can get much more
details than the resource type.
Good luck,
--
Willem Bogaerts
Application smith
Kratz B.V.
http://www.kratz.nl/
On 19 Oct, 11:02, "Kye"
> Can anybody please suggest to me where I can look up what a Resource id #71
> is??? No success so far looking for what the resource codes are on the net.
>
> --
> Yours Sincerely
> Kye
The manual has whole sections explaining about resources.
http://uk2.php.net/manual/en/language.types.resource.php
so I don't know where you were looking.
> As far as I know, that is the 71st resource you create in your script.
> There are functions for getting the type of the resource if you don't
> know it. A resource is a PHP-special data type and is used for files,
> database connections and a lot more. I don't think you can get much more
> details than the resource type.
So is there any way to know why :
I am currently occupied smacking myself for looking at this for AGES and
missing the obvious. Thanks Paralytic for the manual reference that led me
to what I was doing wrong.
Thankyou also Willem for helping me even though I (as usual) was the error.
--
Yours Sincerely
Kye
In our last episode,
lovely and talented Kye broadcast on comp.lang.php:
>> As far as I know, that is the 71st resource you create in your script.
>> There are functions for getting the type of the resource if you don't
>> know it. A resource is a PHP-special data type and is used for files,
>> database connections and a lot more. I don't think you can get much more
>> details than the resource type.
> So is there any way to know why :
>
> if ( isset($_POST[dropdown]) ) {
> $heading = mysql_query("SELECT links_categories.category,
> links_categories.cat_id FROM links_categories WHERE $_POST[dropdown] =
> links_categories.cat_id") or die('Error, Heading select failed');
> } else {
> $heading = "Markets, Fairs, Fetes and Field Days";
> }
> echo $heading; ?>
> is returning a Resource ID # 71 or occasionally # 73???
That's right. $heading is a Resource ID. What number it is depends upon
the particular instance of your query within your script. It is merely a
handle on the return of your query. You must fetch your result according to
the type of result you expect. See the mysql_fetch_* functions in the
manual. If you expect a row use mysql_fetch_row($heading), if you expect a
hash use mysql_fetch_assoc($heading) and so forth. Because resources are
pretty much meaningless outside of particular query instances, they are
usually named something like $result, for example:
if ( isset($_POST[dropdown]) ) {
$result = mysql_query("SELECT links_categories.category,
links_categories.cat_id FROM links_categories WHERE $_POST[dropdown] =
links_categories.cat_id") or die('Error, Heading select failed');
$heading = mysql_fetch_row($result);
$heading = my_function_to_make_heading_pretty($heading);
} else {
$heading = "Markets, Fairs, Fetes and Field Days";
}
echo $heading; ?>
If you experiment with the mysql client on the command line and try using it
in contexts in which you pipe results to other programs you will soon
understand that mysql results can be interpreted in different ways which is
why PHP gives you a handle on results so you can choose the appropriate
interpretation.
Also, because line breaks, quoting, escaping, and so forth in the query
string can be messy, it is typical practice to compose the query string
outside the mysql_query.
if ( isset($_POST[dropdown]) ) {
$query = 'query string ' . "carnage" . ' and ugliness';
$result = mysql_query($query) or die('Error, Heading select failed');
$heading = mysql_fetch_row($result);
$heading = my_function_to_make_heading_pretty($heading);
} else {
$heading = "Markets, Fairs, Fetes and Field Days";
}
echo $heading; ?>
Really, there are many examples with the mysql functions in the manual. It
would pay you to study them.
--
Lars Eighner
Countdown: 459 days to go.
What do you do when you're debranded?
..oO(Kye)
>> As far as I know, that is the 71st resource you create in your script.
>> There are functions for getting the type of the resource if you don't
>> know it. A resource is a PHP-special data type and is used for files,
>> database connections and a lot more. I don't think you can get much more
>> details than the resource type.
>
>So is there any way to know why :
>
>