Re: SELECT statement does not return rows

From: Date: Fri, 01 Feb 2002 23:12:04 +0000
Subject: Re: SELECT statement does not return rows
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-16431@lists.php.net to get a copy of this message
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 <todd@williamsen.net> 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> > <Title>Edit Job Posting</title> > </head> > <body> > <h1>Edit 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> > <th>Job Information and Location</th> > <th>Job Description</th> > </tr> > <tr> > <td valign=top> > <p><strong>Job Title:</strong><br> > <input type="text" name="JobTitle" value="<?php echo > "$JobTitle"?>" size=50 > maxlength=75></p> > <p><strong>Industry:</strong><br> > <input type="text" name="Industry" value="<? echo > "$Industry"; ?>" size=50 > maxlength=75></p> > <p><strong>Other:</strong><br> > <input type="text" name="Other" value="<? echo > "$Other";?>" size=50 > maxlength=75></p> > <p><strong>Location:</strong><br> > <inout type="text" name="Location" value="<? echo > "$Location"; ?>" size=50 > maxlength=75></p> > <p><strong>Date:</strong><br> > <input type="text" name="Date" value="<? echo "$Date"; > ?>" size=30 > maxlength=40></p> > </td> > <td valign=top> > <p><strong>Description:</strong><br> > <textarea name="Description" cols="50" > rows="10"><? echo > "$Description"; ?></textarea> > </p> > </td> > </tr> > <tr> > <td align=center colspan=2><br> > <p><input 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: php-db-unsubscribe@lists.php.net > For additional commands, e-mail: php-db-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net > --

« previous php.db (#16431) next »