Jump to content

[SOLVED] erro when want to update some stuff


demonforce

Recommended Posts

When i want to update an table, i get this error:

 

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 'ben vandaag aan dit project begonnen, om mijn uren te vermelden, handig, makkeli' at line 1

 

this is with these scrips

 

Bewerkuren.php

<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<style type="text/css">
<!--
.style2 {color: #999900}
.style3 {
color: #000000;
font-weight: bold;
}
.style5 {color: #999900; font-weight: bold; }
-->
</style>
</head>
<body bgcolor="#666666">

<?php

require("mysql.connect.php");

if(isset($_GET['id'])){
     if(!is_numeric($_GET['id'])){
           die('The page doesnt exists');
     }
     $id = mysql_real_escape_string($_GET['id']);
     $query = @mysql_query("SELECT * FROM uren WHERE id='$id'") or die(mysql_error());
     $values = mysql_fetch_array($query);
}

echo '<form action="http://84.24.104.234/uren/verzondenbewerkuren.php" method="post">
<table width="212" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="68" class="style3"><input name="id" type="text" id="id" maxlength="9999" value="'.$values['id'].'"/>niet veranderen!</td>
    <td width="144"><div align="center"></div></td>
  </tr>
  <tr>
    <td valign="top" class="style3">Week NR </td>';
echo '    <td><input name="weeknr" type="text" id="weeknr" maxlength="9999" value="'.$values['weeknr'].'"/></td>';
echo '  </tr>
  <tr>
    <td valign="top" class="style3">Datum1</td>';
echo '        <td><input name="datum1" type="text" id="datum1" maxlength="9999" value="'.$values['datum1'].'"/></td>';
echo '      </tr>
  <tr>
    <td valign="top" class="style3">Bericht1</td>';
echo '        <td><textarea name="bericht1" cols="21" rows="10" id="bericht1">'.$values['bericht1'].'</textarea></td>';
echo '      </tr>
  <tr>
    <td valign="top" class="style3">Uren1</td>';
echo '        <td><input name="uren1" type="text" id="uren1" maxlength="9999" value="'.$values['uren1'].'"/></td>';
echo '      </tr>
  <tr>
    <td valign="top" class="style3">Datum2</td>';
echo '        <td><input name="datum2" type="text" id="datum2" maxlength="9999" value="'.$values['datum2'].'"/></td>';
echo '      </tr>
  <tr>
    <td valign="top" class="style3">Bericht2</td>';
echo '        <td><textarea name="bericht2" cols="21" rows="10" id="bericht2">'.$values['bericht2'].'</textarea></td>';
echo '      </tr>
  <tr>
    <td valign="top" class="style3">Uren2</td>';
echo '        <td><input name="uren2" type="text" id="uren2" maxlength="9999" value="'.$values['uren2'].'"/></td>';
echo '      </tr>
  <tr>
    <td valign="top" class="style3">Datum3</td>';
echo '        <td><input name="datum3" type="text" id="datum3" maxlength="9999" value="'.$values['datum3'].'"/></td>';
echo '      </tr>
  <tr>
    <td valign="top" class="style3">Bericht2</td>';
echo '        <td><textarea name="bericht3" cols="21" rows="10" id="bericht3">'.$values['bericht3'].'</textarea></td>';
echo '      </tr>
  <tr>
    <td valign="top" class="style3">Uren3</td>';
echo '        <td><input name="uren3" type="text" id="uren3" maxlength="9999" value="'.$values['uren3'].'"/></td>';
echo '      </tr>';
echo '      <tr>
    <td class="style3"><input type="submit" name="Submit" value="Inzenden" /></td>
    <td><div align="center">
      <input type="reset" name="reset" value="Resetten" />
    </div></td>
  </tr>
</table>';
?>
</body>
</html>

 

verzondenbewerkuren.php

<html>
<head>
<title>*</title>
</head>
<body bgcolor="771111">
<?php
$id = $_POST["id"];
$weeknr = $_POST["weeknr"];
$datum1 = $_POST["datum1"];
$bericht1 = $_POST["bericht1"];
$uren1 = $_POST["uren1"];
$datum2 = $_POST["datum2"];
$bericht2 = $_POST["bericht2"];
$uren2 = $_POST["uren2"];
$datum3 = $_POST["datum3"];
$bericht3 = $_POST["bericht3"];
$uren3 = $_POST["uren3"];
?>

<?php

require('mysql.connect.php');

$sql = "UPDATE uren SET `weeknr` = ".$weeknr.", `datum1` = ".$datum1." , `bericht1` = ".$bericht1." , `uren1` = ".$uren1." , `datum2` = ".$datum2." , `bericht2` = ".$bericht2." , `uren2` = ".$uren2." ,  `datum3` = ".$datum3." , `bericht3` = ".$bericht3." , `uren3` = ".$uren3."' WHERE `id` = ".$id."";
mysql_query($sql) or die(mysql_error());

echo "<font size='6'>hij staat erin.</font>";
echo "<meta http-equiv='REFRESH' content='10;URL=index.php'>";
?>
</body>
</html>

 

 

i dont get why i get the error :/

Link to comment
Share on other sites

Try this..

 

 

$sql = "UPDATE uren SET weeknr = '$weeknr',datum1 = '$datum1' , bericht1 = '$bericht1' , uren1 = '$uren1' , datum2 = '$datum2' , bericht2 = '$bericht2' , uren2 = '$uren2' ,  datum3 = '$datum3' , bericht3 = '$bericht3' , uren3 = '$uren3' WHERE id = '$id'";

 

 

There is no need to concatenate the string within the query. Just surround the whole query with " and surround the vars with ' works for me every time.

 

Nate

Link to comment
Share on other sites

okay, i now did this like you said:

 

$sql = "UPDATE uren SET weeknr = $weeknr, datum1 = $datum1 , bericht1 = $bericht1 , uren1 = $uren1 , datum2 = $datum2 , bericht2 = $bericht2 , uren2 = $uren2 ,  datum3 = $datum3 , bericht3 = $bericht3 , uren3 = $uren3 WHERE `id` = $id";
mysql_query($sql) or die(mysql_error());

 

 

but i still get the same error :/

Link to comment
Share on other sites

i did that, and now i get this error with this code:

 

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 '1'' at line 1

 

<html>
<head>
<title>*</title>
</head>
<body bgcolor="771111">
<?php
$id = $_POST["id"];
$weeknr = $_POST["weeknr"];
$datum1 = $_POST["datum1"];
$bericht1 = $_POST["bericht1"];
$uren1 = $_POST["uren1"];
$datum2 = $_POST["datum2"];
$bericht2 = $_POST["bericht2"];
$uren2 = $_POST["uren2"];
$datum3 = $_POST["datum3"];
$bericht3 = $_POST["bericht3"];
$uren3 = $_POST["uren3"];
?>

<?php

require('mysql.connect.php');

$sql = "UPDATE uren SET weeknr = '".$_POST['weeknr']."', datum1 = '".$_POST['datum1']."', bericht1 = '".$_POST['bericht1']."', uren1 = '".$_POST['uren1']."', datum2 = '".$_POST['datum2']."', bericht2 = '".$_POST['bericht2']."', uren2 = '".$_POST['uren2']."',  datum3 = '".$_POST['datum3']."', bericht3 = '".$_POST['bericht3']."', uren3 = '".$_POST['uren3']."' ' WHERE id =  '".$_POST['id']."'";
mysql_query($sql) or die(mysql_error());

echo "<font size='6'>hij staat erin.</font>";
echo "<meta http-equiv='REFRESH' content='10;URL=index.php'>";
?>
</body>
</html>

Link to comment
Share on other sites

okay, i now did this like you said:

 

$sql = "UPDATE uren SET weeknr = $weeknr, datum1 = $datum1 , bericht1 = $bericht1 , uren1 = $uren1 , datum2 = $datum2 , bericht2 = $bericht2 , uren2 = $uren2 ,  datum3 = $datum3 , bericht3 = $bericht3 , uren3 = $uren3 WHERE `id` = $id";
mysql_query($sql) or die(mysql_error());

 

 

but i still get the same error :/

 

 

No you did not do like I said. Surround your vars with ' '. and take out the ` from the id part.

 

Just copy and paste what I gave ya in the last post. I just copied your code and took it into notepad and removed the stuff that was not needed and added the single quotes.

 

Nate

 

 

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.