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
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'";

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.