[PHP-DB] SELECT statement does not return rows

2002-02-01 Thread Todd Williamsen

Weird..

I want to be able to edit records, which I have done in the past, and I
cannot see why it isn't working...  I have tried single qoutes around the
$row =  and that doesn't work either.  here is the code:

$db = @mysql_select_db($db_name, $connection) or die(Could not select
database);
$sql=SELECT * FROM Jobs WHERE id = '$id' ;
$result = mysql_query($sql,$connection) or die(Couldn't execute query);
while ($row = mysql_fetch_array($result))
{
$id = $row[id];
$Industry = $row[Industry];
$Other = $row[Other];
$JobTitle = $row[JobTitle];
$Description = $row[Description];
$Location = $row[Location];
$Date = $row[Date];
}
?
html
head
TitleEdit Job Posting/title
/head
body
h1Edit Job Posting/h1
form method=post action=do_mod_job.php
input type=hidden name=id value=? echo $id; ?
  table cellspacing=3 cellpadding=5 align=center
tr
thJob Information and Location/th
thJob Description/th
/tr
tr
td valign=top
pstrongJob Title:/strongbr
input type=text name=JobTitle value=?php echo $JobTitle? size=50
maxlength=75/p
pstrongIndustry:/strongbr
input type=text name=Industry value=? echo $Industry; ? size=50
maxlength=75/p
pstrongOther:/strongbr
input type=text name=Other value=? echo $Other;? size=50
maxlength=75/p
pstrongLocation:/strongbr
inout type=text name=Location value=? echo $Location; ? size=50
maxlength=75/p
pstrongDate:/strongbr
input type=text name=Date value=? echo $Date; ? size=30
maxlength=40/p
/td
td valign=top
pstrongDescription:/strongbr
  textarea name=Description cols=50 rows=10? echo
$Description; ?/textarea
/p
/td
/tr
tr
td align=center colspan=2br
pinput type=submit name=submit value=Update Job/p
br
/td
/tr
/table
/form
/body
/html



-- 
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] SELECT statement does not return rows

2002-02-01 Thread Rick Emery

Did you print out the value of $sql before executing it?  Was it as you
expected?
If so, did you print out mysql_num_rows() to verify it's greater than 0?

-Original Message-
From: Todd Williamsen [mailto:[EMAIL PROTECTED]]
Sent: Friday, February 01, 2002 2:52 PM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] SELECT statement does not return rows


Weird..

I want to be able to edit records, which I have done in the past, and I
cannot see why it isn't working...  I have tried single qoutes around the
$row =  and that doesn't work either.  here is the code:

$db = @mysql_select_db($db_name, $connection) or die(Could not select
database);
$sql=SELECT * FROM Jobs WHERE id = '$id' ;
$result = mysql_query($sql,$connection) or die(Couldn't execute query);
while ($row = mysql_fetch_array($result))
{
$id = $row[id];
$Industry = $row[Industry];
$Other = $row[Other];
$JobTitle = $row[JobTitle];
$Description = $row[Description];
$Location = $row[Location];
$Date = $row[Date];
}
?
html
head
TitleEdit Job Posting/title
/head
body
h1Edit Job Posting/h1
form method=post action=do_mod_job.php
input type=hidden name=id value=? echo $id; ?
  table cellspacing=3 cellpadding=5 align=center
tr
thJob Information and Location/th
thJob Description/th
/tr
tr
td valign=top
pstrongJob Title:/strongbr
input type=text name=JobTitle value=?php echo $JobTitle? size=50
maxlength=75/p
pstrongIndustry:/strongbr
input type=text name=Industry value=? echo $Industry; ? size=50
maxlength=75/p
pstrongOther:/strongbr
input type=text name=Other value=? echo $Other;? size=50
maxlength=75/p
pstrongLocation:/strongbr
inout type=text name=Location value=? echo $Location; ? size=50
maxlength=75/p
pstrongDate:/strongbr
input type=text name=Date value=? echo $Date; ? size=30
maxlength=40/p
/td
td valign=top
pstrongDescription:/strongbr
  textarea name=Description cols=50 rows=10? echo
$Description; ?/textarea
/p
/td
/tr
tr
td align=center colspan=2br
pinput type=submit name=submit value=Update Job/p
br
/td
/tr
/table
/form
/body
/html



-- 
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] SELECT statement does not return rows

2002-02-01 Thread biorn

Is your id an integer or a char/varchar?  If it is an integer, take the 
quotes off $id in your select statement.  

Todd Williamsen [EMAIL PROTECTED] said:

 Weird..
 
 I want to be able to edit records, which I have done in the past, and I
 cannot see why it isn't working...  I have tried single qoutes around the
 $row =  and that doesn't work either.  here is the code:
 
 $db = @mysql_select_db($db_name, $connection) or die(Could not select
 database);
 $sql=SELECT * FROM Jobs WHERE id = '$id' ;
 $result = mysql_query($sql,$connection) or die(Couldn't execute query);
 while ($row = mysql_fetch_array($result))
 {
 $id = $row[id];
 $Industry = $row[Industry];
 $Other = $row[Other];
 $JobTitle = $row[JobTitle];
 $Description = $row[Description];
 $Location = $row[Location];
 $Date = $row[Date];
 }
 ?
 html
 head
 TitleEdit Job Posting/title
 /head
 body
 h1Edit Job Posting/h1
 form method=post action=do_mod_job.php
 input type=hidden name=id value=? echo $id; ?
   table cellspacing=3 cellpadding=5 align=center
 tr
 thJob Information and Location/th
 thJob Description/th
 /tr
 tr
 td valign=top
 pstrongJob Title:/strongbr
 input type=text name=JobTitle value=?php echo $JobTitle? size=50
 maxlength=75/p
 pstrongIndustry:/strongbr
 input type=text name=Industry value=? echo $Industry; ? size=50
 maxlength=75/p
 pstrongOther:/strongbr
 input type=text name=Other value=? echo $Other;? size=50
 maxlength=75/p
 pstrongLocation:/strongbr
 inout type=text name=Location value=? echo $Location; ? size=50
 maxlength=75/p
 pstrongDate:/strongbr
 input type=text name=Date value=? echo $Date; ? size=30
 maxlength=40/p
 /td
 td valign=top
 pstrongDescription:/strongbr
   textarea name=Description cols=50 rows=10? echo
 $Description; ?/textarea
 /p
 /td
 /tr
 tr
 td align=center colspan=2br
 pinput type=submit name=submit value=Update Job/p
 br
 /td
 /tr
 /table
 /form
 /body
 /html
 
 
 
 -- 
 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] SELECT statement does not return rows

2002-02-01 Thread Shrock, Court

I am assuming that this code is NOT the file do_mod_job.php.

What happens if you do this next line right after you execute your query?:

echo 'num rows fetched: '.mysql_num_rows($result).'br';

also, the while loop shouldn't really be necessary as the query should only
return one record if I understand the naming of your fields correctly.  Your
echo statements don't have to have the variable encapsulated with
double-quotes either--it is actually easier on PHP if they are not (if you
use single-quotes rather than double-quotes as well when appropriate).

If there is a row being returned from the query as discovered above, you
might try the following to make sure that what you are getting is what you
are expecting:

$row = mysql_fetch_array($result)
echo 'tabletrthcolumn/ththvalue/th/tr';
while(list($key, $val) = each($row)) {
  // $row has two key/value pairs per column -- one integer, one string
  if (is_string($key)) {
echo trtd$key/tdtd$val/td/tr;
  }
}
echo '/table';
exit;

basically, you need to verify that $row['id'] is not empty.


 -Original Message-
 Todd Williamsen [EMAIL PROTECTED] said:
 
  Weird..
  
  I want to be able to edit records, which I have done in the 
 past, and I
  cannot see why it isn't working...  I have tried single 
 qoutes around the
  $row =  and that doesn't work either.  here is the code:
  
  $db = @mysql_select_db($db_name, $connection) or die(Could 
 not select
  database);
  $sql=SELECT * FROM Jobs WHERE id = '$id' ;
  $result = mysql_query($sql,$connection) or die(Couldn't 
 execute query);
  while ($row = mysql_fetch_array($result))
  {
  $id = $row[id];
  $Industry = $row[Industry];
  $Other = $row[Other];
  $JobTitle = $row[JobTitle];
  $Description = $row[Description];
  $Location = $row[Location];
  $Date = $row[Date];
  }
  ?
  html
  head
  TitleEdit Job Posting/title
  /head
  body
  h1Edit Job Posting/h1
  form method=post action=do_mod_job.php
  input type=hidden name=id value=? echo $id; ?
table cellspacing=3 cellpadding=5 align=center
  tr
  thJob Information and Location/th
  thJob Description/th
  /tr
  tr
  td valign=top
  pstrongJob Title:/strongbr
  input type=text name=JobTitle value=?php echo 
 $JobTitle? size=50
  maxlength=75/p
  pstrongIndustry:/strongbr
  input type=text name=Industry value=? echo 
 $Industry; ? size=50
  maxlength=75/p
  pstrongOther:/strongbr
  input type=text name=Other value=? echo $Other;? size=50
  maxlength=75/p
  pstrongLocation:/strongbr
  inout type=text name=Location value=? echo 
 $Location; ? size=50
  maxlength=75/p
  pstrongDate:/strongbr
  input type=text name=Date value=? echo $Date; ? size=30
  maxlength=40/p
  /td
  td valign=top
  pstrongDescription:/strongbr
textarea name=Description cols=50 rows=10? echo
  $Description; ?/textarea
  /p
  /td
  /tr
  tr
  td align=center colspan=2br
  pinput type=submit name=submit value=Update Job/p
  br
  /td
  /tr
  /table
  /form
  /body
  /html

-- 
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] SELECT statement does not return rows

2002-02-01 Thread Shrock, Court

oops.forgot a semicolon on the first line of the multi-line code
segment

 -Original Message-
 $row = mysql_fetch_array($result)
 echo 'tabletrthcolumn/ththvalue/th/tr';
 while(list($key, $val) = each($row)) {
   // $row has two key/value pairs per column -- one integer, 
 one string
   if (is_string($key)) {
 echo trtd$key/tdtd$val/td/tr;
   }
 }

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