Re: [PHP-DB] mysql_result()

2001-04-05 Thread Jordan Elver

Thanks for everyones help with this one, all suggestions appreciated.

Cheers,

Jord

On Wednesday 04 April 2001 17:06, you wrote:
 Jordan,

 If you know your result is going to product one row, try using:

 $row=mysql_fetch_array($result, MSQL_ASSOC);
 // returns an assoc array where the field names are keys, field value is
 value

 $id=row[id];
 $name=row[name];
 etc.

 Best regards,
 Andrew
 --
 Andrew Hill - OpenLink Software
 Director Technology Evangelism
 eBusiness Infrastructure Technology
 http://www.openlinksw.com

  -Original Message-

  From: Jordan Elver [mailto:[EMAIL PROTECTED]]
  Sent: Wednesday, April 04, 2001 11:46 AM
  To: PHP Database Mailing List; PHP General Mailing List
  Subject: [PHP-DB] mysql_result()
 
 
  Hi,
  If I knnow that a query will only retrun one row, can I do thiss (below)
  rather than using a while loop for one record?
 
  $id = @mysql_result($result, 0, 'id');
  $name = @mysql_result($result, 0, 'name');
  $email = @mysql_result($result, 0, 'email');
  $address1 = @mysql_result($result, 0, 'address1');
  $address2 = @mysql_result($result, 0, 'address2');
  $town_city = @mysql_result($result, 0, 'town_city');
  $postcode = @mysql_result($result, 0, 'postcode');
 
  Cheers,
 
  Jord
 
  --
  PHP Database Mailing List (http://www.php.net/)
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
  To contact the list administrators, e-mail: [EMAIL PROTECTED]

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP-DB] mysql_result()

2001-04-04 Thread Mark Roedel

 -Original Message-
 From: Jordan Elver [mailto:[EMAIL PROTECTED]]
 Sent: Wednesday, April 04, 2001 10:46 AM
 To: PHP Database Mailing List; PHP General Mailing List
 Subject: [PHP-DB] mysql_result()
 
 
 If I knnow that a query will only retrun one row, can I do 
 this (below) rather than using a while loop for one record?
 
 $id = @mysql_result($result, 0, 'id');
 $name = @mysql_result($result, 0, 'name');
 $email = @mysql_result($result, 0, 'email');
 $address1 = @mysql_result($result, 0, 'address1');
 $address2 = @mysql_result($result, 0, 'address2');
 $town_city = @mysql_result($result, 0, 'town_city');
 $postcode = @mysql_result($result, 0, 'postcode');

Looks reasonable to me...what happens when you try it?


---
Mark Roedel ([EMAIL PROTECTED])  ||  "There cannot be a crisis next week.
Systems Programmer / WebMaster  ||   My schedule is already full."
 LeTourneau University  ||-- Henry Kissinger


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP-DB] mysql_result()

2001-04-04 Thread Andrew Hill

Jordan,

If you know your result is going to product one row, try using:

$row=mysql_fetch_array($result, MSQL_ASSOC);
// returns an assoc array where the field names are keys, field value is
value

$id=row[id];
$name=row[name];
etc.

Best regards,
Andrew
--
Andrew Hill - OpenLink Software
Director Technology Evangelism
eBusiness Infrastructure Technology
http://www.openlinksw.com

 -Original Message-
 From: Jordan Elver [mailto:[EMAIL PROTECTED]]
 Sent: Wednesday, April 04, 2001 11:46 AM
 To: PHP Database Mailing List; PHP General Mailing List
 Subject: [PHP-DB] mysql_result()


 Hi,
 If I knnow that a query will only retrun one row, can I do thiss (below)
 rather than using a while loop for one record?

 $id = @mysql_result($result, 0, 'id');
 $name = @mysql_result($result, 0, 'name');
 $email = @mysql_result($result, 0, 'email');
 $address1 = @mysql_result($result, 0, 'address1');
 $address2 = @mysql_result($result, 0, 'address2');
 $town_city = @mysql_result($result, 0, 'town_city');
 $postcode = @mysql_result($result, 0, 'postcode');

 Cheers,

 Jord

 --
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]




-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DB] mysql_result()

2001-04-04 Thread Jordan Elver

Hi,
If I knnow that a query will only retrun one row, can I do thiss (below) 
rather than using a while loop for one record?

$id = @mysql_result($result, 0, 'id');
$name = @mysql_result($result, 0, 'name');
$email = @mysql_result($result, 0, 'email');
$address1 = @mysql_result($result, 0, 'address1');
$address2 = @mysql_result($result, 0, 'address2');
$town_city = @mysql_result($result, 0, 'town_city');
$postcode = @mysql_result($result, 0, 'postcode');

Cheers,

Jord

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DB] mysql_result

2001-03-20 Thread Shahmat Dahlan

I'm trying to use mysql_result to extract data from one particular field
in a record. So I suppose the most viable solution is to use
mysql_result. But when I do this:

$sqlstmt="SELECT * FROM dept WHERE shortname=$shortname";
$result=mysql_query($sqlstmt);
$temp=mysql_result($result,0,"shortname"); -- This will give me an
error

Did I do anything wrong here?

Thanks in advance.
Shahmat


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] mysql_result

2001-03-20 Thread Shahmat Dahlan

I've tried what you suggested and it works, thanks.


Russ Michell wrote:

 Try:

 $sqlstmt="SELECT * FROM dept WHERE shortname='$shortname'";
 //Include single quotes..

 Russ

 #---#

  "Believe nothing - consider everything"

   Russ Michell
   Anglia Polytechnic University Webteam
   http://gertrude.sipu.anglia.ac.uk/webteam
   [EMAIL PROTECTED]
   +44 (0)1223 363271 ext 2331

   www.theruss.com

 #---#


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] mysql_result

2001-03-20 Thread Shahmat Dahlan

That didn't quite work, I tried using single quote enclose within double
quotes and it works.
$sqlstmt="SELECT * FROM dept WHERE shortname='$shortname'";

Thanks anyway


ben wrote:

 On Tue, 20 Mar 2001, Shahmat Dahlan wrote:

  I'm trying to use mysql_result to extract data from one particular field
  in a record. So I suppose the most viable solution is to use
  mysql_result. But when I do this:
 
  $sqlstmt="SELECT * FROM dept WHERE shortname=$shortname";
  $result=mysql_query($sqlstmt);
  $temp=mysql_result($result,0,"shortname"); -- This will give me an
  error
 
  Did I do anything wrong here?
 
  Thanks in advance.
  Shahmat

 The problem is that the query is wrong. Try
 $sqlstmt="SELECT * FROM dept WHERE shortname=\"$shortname\"";

 (you need to send quotes to mysql if the type of shortname in your
 database is text or the like, that's why there's the \"$var\")

 --
 Ben
 History is curious stuff You'd think by now we had enough Yet the fact
 remains I fear They make more of it every year.


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]