Jump to content

My simple form's not showing up...


lilbadger25

Recommended Posts

This should be a simple thing, but I have apparently moved something to the wrong place, or deleted something important. I'm sure someone with an educated eye will be able to spot the issue right away (hopefully).

 

<?php 	
require_once('../connections/ste.php'); 
$connection = mysql_connect($hostname_site, $username_site, $password_site) or die ("Unable to connect!");
mysql_select_db($database_site);
$qry = mysql_query("SELECT * FROM clients") or trigger_error("SQL", E_USER_WARNING);
while($row == mysql_fetch_assoc($qry)) {
    $id = $row["clientID"];
    $clientName = $row["client"];
    $clientURL = $row["address"];

if (!isset($_POST['action'])) {
?>
<table align="left" cellpadding="5" cellspacing="5">
  <form action="<? echo $PHP_SELF; ?>" method="post">
    <input type="hidden" name="clientID"  value="<? echo $id; ?>" />
    <tr>
      <td valign="top" align="left"><b>Client Name:</b></td>
      <td><input size="50" maxlength="250" type="text" name="clientName" value="<? echo $clientName; ?>" />      </td>
    </tr>
        <tr>
      <td valign="top" align="left"><b>Client URL:</b></td>
      <td><input size="50" maxlength="250" type="text" name="clientURL" value="<? echo $clientURL; ?>" />      </td>
    </tr>
        <tr>
          <td valign="top" align="left"> </td>
          <td align=center><input type="submit" name="action" id="action" value="action" /></td>
        </tr>
          <input type="submit" value="Submit" name="action" />
  </form>
</table>
<?php
$qry = "UPDATE clients SET client = '$clientName', address = '$clientURL', WHERE clientID = '$id'";
$result = mysql_query($qry) or die ("Error in query: $qry. " . mysql_error());
$errorList = array();
$count = 0;

if (sizeof($errorList) == 0)
	echo "Update successful! <a href=clientList.php>Go back to the Client List page.</a>.";
	mysql_close($connection);
	} 
else 
{
echo "The following errors were encountered: <br>";
echo "<ul>";
for ($x=0; $x<sizeof($errorList); $x++)
echo "<li>$errorList[$x]";
 }
echo "</ul>";
 }
?>

 

As with the other script I'm having trouble with, that is similar to this one (but having different issues), the $id comes from the page before. It's a list of clients and if the admin would like to edit a certain client, he clicks the "edit" link that passes the variable. The form should populate with the client's name and url but with this script, the form isn't showing up at all.

 

I've looked at older scripts I've done that do simliar things and I can't pinpoint what the issue is. I've looked at past scripts I've done that do similar things, I've moved things around, and I've either gotten an error or the current result.

 

What's broken?

Link to comment
https://forums.phpfreaks.com/topic/88632-my-simple-forms-not-showing-up/
Share on other sites

I added a } before

if (!isset($_POST['action'])) {

 

I ended up deleting the line:

$count = 0;
if (sizeof($errorList) == 0)

 

because it seemed redundant with

for ($x=0; $x<sizeof($errorList); $x++)

 

(was I wrong?)

 

Now, I get:

Error in query: UPDATE clients SET client = '', address = '', WHERE clientID = '15'. You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE clientID = '15'' at line 1

 

Where the query is

	$qry = "UPDATE clients SET client = '$clientName', address = '$clientURL', WHERE clientID = '$id'";

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.