Re: [PHP-DB] mssql_fetch_array problem

2001-06-20 Thread Jennifer Arcino Demeterio


Thanks for all your answers, but, they still seem not to work.  In my query,
the value of countryname is retrieved as expected but the value of countryid
is not.  There seems to be no value retrieved for countryid.  I am using
PHP4 on IIS4 on an NT machine with SQL Server 7 as the database.
countryname is of type varchar while countryid is type int, indentity,
auto_increment.  I tried listing them by printing the resultset but
countryid still does not have any value.  This could be a quirk that some of
you experienced and I sure would like to hear how you overcame this.


I am posting again the code snippet below:

?
$country_sql = select countryname, countryid from TBL_COUNTRY;
if ($country_query = mssql_query($country_sql)) {
   while ($myrow = mssql_fetch_array($country_query)) {
 $countryid = $myrow[countryid];
 $countryname = $myrow[countryname];
 print countryid is  . $countryid .  ,countryname is  .
$countryname . br;
 }
}
?


Thanks.


-- 
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] mssql_fetch_array problem

2001-06-20 Thread Russ Michell

Ok lets start from the beginning, apologies if this these have been 
mentioned previousely I haven't seent the rest of the thread:

* Make sure 'countryid' is spelled the same in your script as it is in 
  your DB table (I've done this and spent hours banging my head against 
  a brick wall) 
* Ensure they both have the same case.
* Ensure 'countryid' actually contains a value in the DB by looking 
  it up via the command line or your GUI.

These may sound trivial but think about it, why should some values 
return when another does not? What are the differences between the 
datatypes that are and are not returned? Compare them and try altering 
the differences you find to see what happens.

Good luck!
Russ


On Wed, 20 Jun 2001 13:17:23 +0800 Jennifer Arcino Demeterio 
[EMAIL PROTECTED] wrote:

 Thanks for all your answers, but, they still seem not to work.  In my 
 query, the value of countryname is retrieved as expected but the value 
 of countryid is not.  There seems to be no value retrieved for 
 countryid.  I am using PHP4 on IIS4 on an NT machine with SQL Server 7 
 as the database. countryname is of type varchar while countryid is 
 type int, indentity, auto_increment.  I tried listing them by printing 
 the resultset but countryid still does not have any value.  This could 
 be a quirk that some of you experienced and I sure would like to hear 
 how you overcame this.
 
 Thanks.
 
 I am posting again the code snippet below:
 
 ?
 $country_sql = select countryname, countryid from TBL_COUNTRY;
 if ($country_query = mssql_query($country_sql)) {
while ($myrow = mssql_fetch_array($country_query)) {
  $countryid = $myrow[countryid];
  $countryname = $myrow[countryname];
  print countryid is  . $countryid .  ,countryname is  .
 $countryname . br;
  }
 }
 ?
 
 
 
 
 -- 
 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]
 

#---#

  Believe nothing - consider everything   
  
  Russ Michell
  Anglia Polytechnic University Webteam
  
  e: [EMAIL PROTECTED]
  w: www.apu.ac.uk/webteam
  t: +44 (0)1223 363271 x 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] mssql_fetch_array problem

2001-06-20 Thread Angie Tollerson

Jennifer,
Try this code..I am using the same stuff as you with the exception of mysql instead of 
sql..but it may still work:
?
$country_sql = select countryname co_name_val, countryid co_id_val from 
TBL_COUNTRY;
if ($country_query = mssql_query($country_sql)) {
   while ($myrow = mssql_fetch_array($country_query)) {
 $countryid = $myrow[co_id_val];
 $countryname = $myrow[co_name_val];
 print countryid is  . $countryid .  ,countryname is  .
$countryname . br;
 }
}
?
It's kind of a save as type of statment but it works for me! I've had no problems 
with that sql statement.
Angie

 Jennifer Arcino Demeterio [EMAIL PROTECTED] 06/20/01 12:17AM 
Thanks for all your answers, but, they still seem not to work.  In my query,
the value of countryname is retrieved as expected but the value of countryid
is not.  There seems to be no value retrieved for countryid.  I am using
PHP4 on IIS4 on an NT machine with SQL Server 7 as the database.
countryname is of type varchar while countryid is type int, indentity,
auto_increment.  I tried listing them by printing the resultset but
countryid still does not have any value.  This could be a quirk that some of
you experienced and I sure would like to hear how you overcame this.

Thanks.

I am posting again the code snippet below:

?
$country_sql = select countryname, countryid from TBL_COUNTRY;
if ($country_query = mssql_query($country_sql)) {
   while ($myrow = mssql_fetch_array($country_query)) {
 $countryid = $myrow[countryid];
 $countryname = $myrow[countryname];
 print countryid is  . $countryid .  ,countryname is  .
$countryname . br;
 }
}
?




-- 
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] mssql_fetch_array problem

2001-06-19 Thread Michael Rudel

Hi Jennifer,

… I think that you want to display the Countryname in the DropDownBox, won't you ?

Try this one (in your while-loop):


if ($country == $myrow[countryid])
{
   print option value= . $myrow[countryid] .  selected
   . $myrow[countryname]
   . /option
   . \n;
}
else
{
   print option value= . $myrow[countryid] . 
   . $myrow[countryname]
   . /option
   . \n;
}


Hope this helps. If not, plz post what is going wrong.

Greetinx,
  Mike

Michael Rudel
- Web-Development, Systemadministration -
___

Suchtreffer AG
Bleicherstraße 20
D-78467 Konstanz
Germany
fon: +49-(0)7531-89207-17
fax: +49-(0)7531-89207-13
e-mail: mailto:[EMAIL PROTECTED]
internet: http://www.suchtreffer.de
___



 -Original Message-
 From: Jennifer Arcino Demeterio [mailto:[EMAIL PROTECTED]]
 Sent: Tuesday, June 19, 2001 6:18 AM
 To: [EMAIL PROTECTED]
 Subject: [PHP-DB] mssql_fetch_array problem


 hello all,

 hope someone could help me 

 it seems that the mssql_fetch_array did not work as it should
 when the data
 type to be fetch is an integer ... is there any work around for this?

 Below is my script ...

 $country_sql = select countryname, countryid from TBL_COUNTRY;
 if ($country_query = mssql_query($country_sql)) {
while ($myrow = mssql_fetch_array($country_query))
   if ($country == $myrow[countryid]) {
print option value= . $myrow[countryid] .
  selected .
 $countryid . /option;
  } else {
print option value= . $myrow[countryid] .  .
 $countryid . /option;
  }
   }
 }


 Thanks!



 --
 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] mssql_fetch_array problem

2001-06-19 Thread Craig Vincent

Not being able to see your code and not knowing exactly what problem you are
having I can only throw a few guesses here.  If you could elaborate more on
what you are expecting and what you are getting that would be a big help.

snip
$country_sql = select countryname, countryid from TBL_COUNTRY;
/snip

You don't use the value of countryname anywhere in your statement...is it
necessary?

snip
if ($country_query = mssql_query($country_sql)) {
/snip

What is this statement intended to do?  Typical when a query is formed PHP
gives the query an integer id.  But that ID is allocated by PHP and if you
add a new query earlier in the code later on the ID for this query will most
likely change...which then will make it not equal what you're expecting it
to equal...in this case $country_query.

Also on a further note you need to use == instead of = otherwise PHP will
assume the statement is always true.

snip
   while ($myrow = mssql_fetch_array($country_query))
  if ($country == $myrow[countryid]) {
   print option value= . $myrow[countryid] .  selected .
$countryid . /option;
 } else {
   print option value= . $myrow[countryid] .  .
$countryid . /option;
 }
  }
}
/snip

Your while statement is missing a { was this code working when you used
it?
Also unless you need PHP returning the success of printing the text you're
better off using echo instead of print.

Based on what I see this code may be what you're looking for

(untested)
$country_sql = 'SELECT countryid FROM TBL_COUNTRY';
while ($myrow = mssql_fetch_row($country_query)) {
echo option value=$myrow[0];
if ($country == $myrow[0]) { echo  selected$myrow[0]/option; }
else { echo $myrow[0]/option; }
}

Sincerely,

Craig Vincent


-- 
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] mssql_fetch_array problem

2001-06-19 Thread Anil Kumar



try:

 if ($country == intval($myrow[countryid]))

mssql_fetch_array is found to have some weird behavior.
 






On Tue, 19 Jun 2001, Jennifer Arcino Demeterio wrote:

 hello all,
 
 hope someone could help me 
 
 it seems that the mssql_fetch_array did not work as it should when the data
 type to be fetch is an integer ... is there any work around for this?
 
 Below is my script ...
 
 $country_sql = select countryname, countryid from TBL_COUNTRY;
 if ($country_query = mssql_query($country_sql)) {
while ($myrow = mssql_fetch_array($country_query))
   if ($country == $myrow[countryid]) {
print option value= . $myrow[countryid] .  selected .
 $countryid . /option;
  } else {
print option value= . $myrow[countryid] .  .
 $countryid . /option;
  }
   }
 }
 
 
 Thanks!
 
 
 
 

-- 
PGP KEY (GnuPG): http://springboard.dyndns.org/akz/akz.pgp


-- 
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] mssql_fetch_array problem

2001-06-19 Thread Dan Brunner

Hello!!!

Try using the second argument of mysql _fetch_array
MYSQL_NUM

This will insure that an integer is used..



If not let me knowI'll do testing...


Dan Brunner






On Monday, June 18, 2001, at 11:18 PM, Jennifer Arcino Demeterio wrote:

 hello all,

 hope someone could help me 

 it seems that the mssql_fetch_array did not work as it should when the 
 data
 type to be fetch is an integer ... is there any work around for this?

 Below is my script ...

 $country_sql = select countryname, countryid from TBL_COUNTRY;
 if ($country_query = mssql_query($country_sql)) {
while ($myrow = mssql_fetch_array($country_query))
   if ($country == $myrow[countryid]) {
print option value= . $myrow[countryid] .  
 selected .
 $countryid . /option;
  } else {
print option value= . $myrow[countryid] .  .
 $countryid . /option;
  }
   }
 }


 Thanks!



 --
 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]