Jump to content

SQL update statement script problem


anubis

Recommended Posts

Greetings good people. I'm having some trouble with this script.

This is the edit part of a homebrewed resource management system.

 

It worked a couple of months ago, and it's not working anymore.

I'm getting this error:

 

Du fylte ikke inn skjemaet korrekt (Norwegian for "You didnt fill out the form correctly"): 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 '' at line 1

 

I'm guessing there has been a version change on my server that makes this script not work anymore.

 

Any pointers in the right direction would be appreciated.

 

<?php
mb_http_input("utf-8");
mb_http_output("utf-8");

//check if user is logged in
session_start();
if(!session_is_registered(username)){
header("location:index.php");
}
$regusername = $_SESSION['username'];

//include MySql connection info
include("db.php");

//extract posted data
extract($_POST);
$id = $_GET["id"];

//connect to database
mysql_select_db("*****", $dbcnx);
if (! @mysql_select_db("*****") ) {
echo( "<P>Unable to locate the database at this time.</P>" );
exit();
}
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<!-- DW6 -->

<head>
<!-- Copyright 2005 Macromedia, Inc. All rights reserved. -->
<title>Månefestivalen</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="mm_spa.css" type="text/css" />
</head>

<body bgcolor="#990000">
<table width="800" border="0" align="center" cellpadding="1" cellspacing="0" id="header">
  <tr class="darkBluebg">
    <td colspan="4" valign="middle" nowrap="nowrap">
    	<div align="center"><img src="../img/topp.gif" width="852" height="171" /></div>    </td>
  </tr>
  <tr>
    <td colspan="2" class="lightBluebg">
    	<div align="center">
        <a href="list.php" class="one">Hjem</a> | 
        <a href="new.php" class="one">Ny Frivillig</a> | 
        <a href="epost.php" class="one">E-postlister</a> | 
        <a href="http://www.maanefestivalen.no/" class="one">maanefestivalen.no </a> | 
        <a href="logout.php" class="one">Logg ut (<?php echo($regusername); ?>)</a></div>    </td>
  </tr>
  <tr>
    <td colspan="2">
    <div align="center">
<?php
    	if ("1" == $endre) {
	$sql = "UPDATE frivillige SET navn='$navn', tlf='$tlf', alder='$alder', epost='$epost', oppg='$oppg', erfaring='$erfaring', vurdering='$vurdering', plass='$plass', adresse='$adresse', naar='$naar' WHERE id =$id";
  			if (mysql_query($sql)) {
    			echo("<table width=\"400\" border=\"0\" cellpadding=\"1\" cellspacing=\"1\" class=\"Buttons\">");
			echo("<tr><td>");
			echo("Du har nå endret informasjonen om $navn.<br>");
			echo("</td></tr></table>");
  			} else {
    			echo("<P>Du fylte ikke inn skjemaet korrekt: " . mysql_error() . "</P>");
  			}
	}
	$result = mysql_query("SELECT * FROM frivillige WHERE id='$id'");
	$row = mysql_fetch_array($result);
	if (!$result) {
		echo("<P>Error performing query: " .
				mysql_error() . "</P>");
		exit();
	}
    ?>
        <form id="nyfrivillig" name="nyfrivillig" method="post" action="<?php echo($PHP_SELF); ?>">
          <br />
          <table border="1" align="center" cellpadding="1" cellspacing="1" bordercolor="#220103" class="Titles">
        <tr>
          <td colspan="2" class="listtxttwo"><div align="center" class="TitlesUppercase">Endre info om <?php echo($row["navn"]); ?></div></td>
        </tr>
        <tr>
          <td width="97" valign="top" class="listtxttwo">Navn:</td>
          <td width="305" align="left" bgcolor="#FF9900" class="listtxtone"><div align="left">
            <input name="navn" type="text" class="Text" value="<?php echo($row["navn"]); ?>" size="45" />          
          </div></td>
        </tr>
        <tr>
          <td width="97" valign="top" class="listtxttwo">Tlf nr:</td>
          <td width="305" align="left" bgcolor="#FF9900" class="listtxtone"><div align="left">
            <input name="tlf" type="text" class="Text" value="<?php echo($row["tlf"]); ?>" size="45" />
          </div></td>
        </tr>
        <tr>
          <td width="97" valign="top" class="listtxttwo">Alder:</td>
          <td width="305" align="left" bgcolor="#FF9900" class="listtxtone"><div align="left">
            <input name="alder" type="text" class="Text" value="<?php echo($row["alder"]); ?>" size="45" />
          </div></td>
        </tr>
        <tr>
          <td width="97" valign="top" class="listtxttwo">Epost:</td>
          <td width="305" align="left" bgcolor="#FF9900" class="listtxtone"><div align="left">
            <input name="epost" type="text" class="Text" value="<?php echo($row["epost"]); ?>" size="45" />
          </div></td>
        </tr>
        <tr>
          <td valign="top" class="listtxttwo">Adresse:</td>
          <td align="left" bgcolor="#FF9900" class="listtxtone"><div align="left">
            <input name="adresse" type="text" class="Text" value="<?php echo($row["adresse"]); ?>" size="45" />
          </div></td>
        </tr>
        <tr>
          <td valign="top" class="listtxttwo">Kan jobbe når?: </td>
          <td align="left" bgcolor="#FF9900" class="listtxtone"><div align="left">
            <select name="naar" size="1" class="Text">
              <option>Før festivalen</option>
              <option>Under festivalen</option>
              <option>Etter festivalen</option>
              <option>Før og under</option>
              <option>Før og etter</option>
              <option>Under og etter</option>
              <option selected="selected">Hele tiden!</option>
            </select>
          (<?php echo($row["naar"]); ?>)</div></td>
        </tr>
        <tr>
          <td width="97" valign="top" class="listtxttwo">Ønske:</td>
          <td width="305" align="left" bgcolor="#FF9900" class="listtxtone"><div align="left">
            <select name="oppg" class="Text">
              <option value="Scenografi">Scenografi</option>
              <option value="Renhold">Renhold/Miljø</option>
              <option value="Scenearb">Infrastruktur</option>
              <option value="Scenerigg">Scenerigg</option>
              <option value="Festivalavis">Festivalavis</option>
              <option value="Frivilligorganisering">Frivilligorganisering</option>
              <option value="Catering">Intern Catering</option>
              <option value="Aktiviteter">Aktiviteter/Boder</option>
              <option value="Dokumentasjon">Dokumentasjon</option>
              <option value="Backstagerigg">Akkreditering</option>
              <option value="Vakt">Vakt</option>
              <option value="Prspreder">Pr og Presse</option>
              <option value="Bar">Bar</option>
              <option value="Kiosk">Materialforvaltning</option>
              <option value="Billsalg">Billettsalg</option>
              <option value="Trans">Transport</option>
              <option value="Bscrew">Backstagecrew</option>
              <option value="Blcrew">Backlinecrew</option>
              <option value="Grafisk">Web/Grafisk</option>
              <option value="Booking">Booking</option>
              <option value="Artistcrew">Artisthåndtering</option>
              <option value="Festsjef">Festivalrådet</option>
              <option value="Annet" selected="selected">Til disposisjon</option>
              <option value="Inaktive">Inaktive/På vent</option>
            </select>
          (<?php echo($row["oppg"]); ?>)</div></td>
        </tr>
        <tr>
          <td width="97" valign="top" class="listtxttwo">Erfaring:</td>
          <td width="305" align="left" bgcolor="#FF9900" class="listtxtone"><div align="left">
            <textarea name="erfaring" cols="40" rows="4" class="Text"><?php echo($row["erfaring"]); ?></textarea>
          </div></td>
        </tr>
        <tr>
          <td width="97" valign="top" class="listtxttwo">Våre notater/<br />
            Vurdering:</td>
          <td width="305" align="left" bgcolor="#FF9900" class="listtxtone"><div align="left">
            <textarea name="vurdering" cols="40" rows="4" class="Text"><?php echo($row["vurdering"]); ?></textarea>
          </div></td>
        </tr>
        <tr>
          <td width="97" valign="top" class="listtxttwo">Endelig oppgave:</td>
          <td width="305" align="left" bgcolor="#FF9900" class="listtxtone"><div align="left">
            <textarea name="plass" cols="40" rows="4" class="Text"><?php echo($row["plass"]); ?></textarea>
          </div></td>
        </tr>
        <tr class="Buttons">
          <td colspan="2" valign="top" class="listtxttwo"><div align="left"></div>
              <div align="center">
                <input name="Submit" type="submit" class="Titles" value="Endre" />
                <input type="hidden" name="endre" value="1" />
            </div></td>
        </tr>
      </table>
          <br />
        </form>
      </div>
    </td>
  </tr>
</table>
</body>
</html>

 

The names have been changed to protect the innocent.

 

::CHEERS::

 

Link to comment
https://forums.phpfreaks.com/topic/162531-sql-update-statement-script-problem/
Share on other sites

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.