Jump to content

Pls help my UPDATE command isn't working


Ryvan

Recommended Posts

Hello people,

 

At the moment I am really desperate. I've done this script over 20 times now, always with the same script but all of a suddon, it doesn't work anymore. heres the problem:

 

I made a very simple "patient database" for a doctor. Where he can upload patients, alter and delete them. The script to add the patients works fine. now im trying to make a script where he can alter the variables agian, using the UPDATE command. but instead of updating the variables it cleares all the date in the row.

 

can someone help me? here s the entire code:

 

 

<?PHP
		include'connect.php';
		?>
            <?PHP
													$SQL = mysql_query("SELECT * FROM leys_patienten WHERE patientid='".$_REQUEST['patientid']."'");
													while ($row = mysql_fetch_array($SQL))
													{
												?>
        <?PHP
													if ($_POST[submit]) {
													if (!$_POST[volgnummer]) {
													echo "<font size=\"2\" color=\"#990000\"><b>--> Vul een volgnummer in a.u.b. <--</b></font>";
													}
													elseif (!$_POST[naam]) 
													{
													echo "<font size=\"2\" color=\"#990000\"><b>--> Vul een naam in a.u.b. <--</b></font>";
													}
													elseif (!$_POST[voornaam])
													{
													echo "<font size=\"2\" color=\"#990000\"><b>--> Vul een voornaam in a.u.b.! <--</b></font>";
													}
													else {

													mysql_query("UPDATE leys_patienten SET volgnummer='$volgnummer',naam='$naam',voornaam='$voornaam',adres='$adres',postcode='$postcode',plaats='$plaats',telefoon='$telefoon',email='$email',geboortedatum='$geboortedatum',geboorteplaats='$geboorteplaats',opmerkingen='$opmerkingen' WHERE patientid='".$_REQUEST['patientid']."'")
													or die(mysql_error());

													echo "Het patientendossier is succesvol gewijzigd, let op doorschakeling.";?>
        <meta http-equiv="Refresh" content="1; url=patient.php?patientid=<?PHP echo $row['patientid']?>" />
        <?
												}
												}
												?></p>

      <form action="<?$PHP_SELF?>" method="post" name="post" id="post">
        <table width="805" border="0" align="center" cellpadding="0" cellspacing="0">
          <tr>
            <td class="table_forms">Volgnummer*</td>
            <td class="table_forms"><label><input name="volgnummer" type="text" id="volgnummer" value="<?PHP echo $row['volgnummer']?>" size="40" /></label></td>
          </tr>
          <tr>
            <td width="146" class="table_forms">Naam*</td>
            <td width="659" class="table_forms"><label><input name="naam" type="text" id="naam" value="<?PHP echo $row['naam']?>" size="40" /></label></td>
          </tr>
          <tr>
            <td class="table_forms">Voornaam*</td>
            <td class="table_forms"><font color="#FFFFFF" size="2">
              <label><input name="voornaam" type="text" id="voornaam" value="<?PHP echo $row['voornaam']?>" size="40" /></label>
            </font></td>
          </tr>
          <tr>
            <td class="table_forms">Adres </td>
            <td><font color="#FFFFFF" size="2">
              <label><input name="adres" type="text" id="adres" value="<?PHP echo $row['adres']?>" size="40" /></label>
            </font></td>
          </tr>
          <tr>
            <td class="table_forms">Postcode</td>
            <td><font color="#FFFFFF" size="2">
             <label><input name="postcode" type="text" id="postcode" value="<?PHP echo $row['postcode']?>" size="6" /></label>
            </font></td>
          </tr>
          <tr>
            <td class="table_forms">Plaats</td>
            <td><font color="#FFFFFF" size="2">
              <label><input name="plaats" type="text" id="plaats" value="<?PHP echo $row['plaats']?>" size="40" /></label>
            </font></td>
          </tr>
          <tr>
            <td class="table_forms">Telefoon</td>
            <td><font color="#FFFFFF" size="2">
              <label><input name="telefoon" type="text" id="telefoon" value="<?PHP echo $row['telefoon']?>" size="40" /></label>
            </font></td>
          </tr>
          <tr>
            <td class="table_forms">E-mail</td>
            <td><font color="#FFFFFF" size="2">
              <label><input name="email" type="text" id="email" value="<?PHP echo $row['email']?>" size="40" /></label>
            </font></td>
          </tr>
          <tr>
            <td class="table_forms">Geboortedatum</td>
            <td><font color="#FFFFFF" size="2">
              <label><input name="geboortedatum" type="text" id="geboortedatum" value="<?PHP echo $row['geboortedatum']?>" size="40" /></label>
            </font></td>
          </tr>
          <tr>
            <td class="table_forms">Geboorteplaats</td>
            <td><font color="#FFFFFF" size="2">
              <label><input name="geboorteplaats" type="text" id="geboorteplaats" value="<?PHP echo $row['geboorteplaats']?>" size="40" /></label>
            </font></td>
          </tr>
          <tr>
            <td valign="top" class="table_forms">Opmerkingen</td>
            <td><font color="#FFFFFF" size="2">
              <label><textarea name="opmerkingen" cols="40" rows="4" id="opmerkingen"><?PHP echo $row['opmerkingen']?></textarea></label>
            </font></td>
          </tr>
          <tr>
            <td valign="top" class="table_forms"> </td>
            <td><span class="body_tekst">
              <input type="submit" id="submit" name="submit" value="verstuur" />
            </span></td>
          </tr>
        </table>
        <p class="body_tekst"> </p>
      </form>
  <?
	}
  ?>

Link to comment
Share on other sites

Where are your $volgnummer, etc. variables coming from? And before you say "the form" know that the only way that can happen is if you have a

$volgnummer = $_POST["volgnummer"];

in your code. And before you say "but it works in other places" remember that you aren't working in those other places right now.

Link to comment
Share on other sites

Your variables in the UPDATE query are probably empty. I don't see anywhere in the code that you assign the values from the $_POST array to the variables in the query string. You should be developing with the following directives set in your php.ini file so these types of errors are reported.

error_reporting = -1

display_errors = On

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.