Re: MySQL: How to properly extract fields from retrieved single record ???

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



read the PHP manual and examples under the function mysql_fetch_array().

I find the MySQL manual is very well done and helpful. I've been using it as
a reference for 2 years. Take a harder look!

Ignatius
_________________________
----- Original Message -----
From: "-{ Rene Brehmer }-" <metalbunny@metalbunny.net>
To: <php-db@lists.php.net>
Sent: Monday, September 22, 2003 1:57 PM
Subject:  MySQL: How to properly extract fields from retrieved
single record ???


> Hi gang
>
> Still working on this DB for my gameclan.... not that it's essential what
> it's for... and be warned: Never worked with any form of DB in PHP before
I
> began this project, so I'm a total n00b at these MySQL commands (and the
> manual for MySQL is by far nowhere near as good as the PHP one).
>
> Anyways, I'm retrieving a single record from the DB table, and then,
> because of the way the data needs to be displayed and manipulated, need to
> extract every single field from that record as a seperate value.
>
> I tried this:
>
>      $num2edit = $_POST['edit'];
>      $link = mysql_connect($host,$username,$password)
>        or die('Could not connect : '.mysql_error());
>      mysql_select_db($database) or die('Could not select database');
>
>      $query = "SELECT
> countryNum,country,nw,gov,strat,spy,troops,jets,turrets,tanks,ally,owner
> FROM a2a WHERE countryNum=$num2edit";
>      $result = mysql_query($query);
>
>      $countryNum = mysql_result($result,1,'countryNum');
>      $country = mysql_result($result,1,'country');
>      $nw = mysql_result($result,1,'nw');
>      $gov = mysql_result($result,1,'gov');
>      $strat = mysql_result($result,1,'strat');
>      $spy = mysql_result($result,1,'spy');
>      $troops = mysql_result($result,1,'troops');
>      $jets = mysql_result($result,1,'jets');
>      $turrets = mysql_result($result,1,'turrets');
>      $tanks = mysql_result($result,1,'tanks');
>      $ally = mysql_result($result,1,'ally');
>      $owner = mysql_result($result,1,'owner');
>
>      /* Free resultset */
>      mysql_free_result($result);
>      /* Closing connection */
>      mysql_close($link);
>
> But all it gives me are errors like this:
>
> Warning: mysql_result(): supplied argument is not a valid MySQL result
> resource in E:\web\mpe\a2aedit.php on line 350
> Warning: mysql_result(): supplied argument is not a valid MySQL result
> resource in E:\web\mpe\a2aedit.php on line 351
> Warning: mysql_result(): supplied argument is not a valid MySQL result
> resource in E:\web\mpe\a2aedit.php on line 352
> Warning: mysql_result(): supplied argument is not a valid MySQL result
> resource in E:\web\mpe\a2aedit.php on line 353
> Warning: mysql_result(): supplied argument is not a valid MySQL result
> resource in E:\web\mpe\a2aedit.php on line 354
> Warning: mysql_result(): supplied argument is not a valid MySQL result
> resource in E:\web\mpe\a2aedit.php on line 355
> Warning: mysql_result(): supplied argument is not a valid MySQL result
> resource in E:\web\mpe\a2aedit.php on line 356
> Warning: mysql_result(): supplied argument is not a valid MySQL result
> resource in E:\web\mpe\a2aedit.php on line 357
> Warning: mysql_result(): supplied argument is not a valid MySQL result
> resource in E:\web\mpe\a2aedit.php on line 358
> Warning: mysql_result(): supplied argument is not a valid MySQL result
> resource in E:\web\mpe\a2aedit.php on line 359
> Warning: mysql_result(): supplied argument is not a valid MySQL result
> resource in E:\web\mpe\a2aedit.php on line 360
> Warning: mysql_result(): supplied argument is not a valid MySQL result
> resource in E:\web\mpe\a2aedit.php on line 361
>
> Obviously, the first mysql_result line is line 350 in the full code. I've
> also tried changing the row number to 0, but results in the same errors.
>
> I can't find any decent reference on the web that shows how to do this -
> field extraction - when there's only the single record. So I've been
mixing
> code from various places. And I don't even know if it retrieves the right
> record, or any record at all (how do I test that?).
>
> Any help is highly appreciated :)
>
> TIA
>
> Rene
> --
> Rene Brehmer
> aka Metalbunny
>
> http://metalbunny.net/
> References, tools, and other useful stuff...
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux