Jump to content

Recommended Posts

ok how is that not a standard (excluding the server not being localhost)?

 

alexander007 @ you will not recieve the 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 'SET comentario='' WHERE id='0'' at line 1

 

from thats script

This what I have on the form that call this script...

 

<?php
session_start();
if(!session_is_registered(username)){
header("location:admin.php");
}
?>
<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">
<!--
.style1 {
font-size: x-large;
font-weight: bold;
}
-->
</style>
</head>
<body>
<?php
include"config.php";
$id=$_GET['id'];
$tbl_name=$_GET['tbl_name'];
$sql="SELECT * FROM $tbl_name WHERE id='$id'";
$result = mysql_query($sql);
$row = mysql_fetch_array($result);
?>
<div align="center" class="style1">Editar Visitante </div>
<form id="form1" name="form1" method="post" action="editvisitante.php">
  <table width="730" border="1" align="center">
    <tr>
      <td width="181"><div align="center"><strong>Nombre</strong></div></td>
      <td width="181"><div align="center"><strong>Telefono</strong></div></td>
      <td width="181"><div align="center"><strong>Email</strong></div></td>
      <td width="159"><div align="center"><strong>Comentario</strong></div></td>
    </tr>
    <tr>
  <td><div align="center"><?php echo $row['nombre'];?></div></td>
      <td><div align="center"><?php echo $row['telefono'];?></div></td>
      <td><div align="center"><?php echo $row['email'];?></div></td>
      <td><textarea name="comentario" id="comentario"><?php echo $row['comentario']; ?></textarea></td>
    </tr>
  </table>
  <p>
    <input name="id" type="hidden" id="id" value="<?php echo $row['id']; ?>"/>
<input name="tbl_name" type="hidden" value="<?php echo $tbl_name; ?>"/>
  </p>
  <p align="center">
    <input type="submit" name="Submit" value="Enviar" />
  </p>
</form>
<?php
mysql_close();
?>

WAIT!

 

Godaddy has a special database connection script. It isn't standard php/mysql. I know because I have godaddy accounts. Maybe this is your problem???

 

$x = "p83mysql62.secureserver.net" ;
$y = "database_name_db" ;
$z = "FunKyPassWoRd" ;
$xyz = @mysql_connect($x,$y,$z);
if (!$xyz) {
    die('Could not connect to database');
}
$db = @mysql_select_db ($y,$xyz);
if (!$db) {
    die ('Database cannot be found');
}

 

I dont think thats the problem...because I can connect to the database etc....

As I was learning mysql today, I took a peak at the different commands for sql

 

at the very top the same error message was brought to attention http://dev.mysql.com/doc/refman/5.0/en/reserved-words.html

 

Now I don't fully understand, but this is where I would start looking,

Cheers

$sql="UPDATE $tbl_name SET comentario='$comentario' WHERE id='$id'";

 

After the UPDATE should there not be some thing else? Update is a command correct?  Should there not be a qualifier or something there?

 

According to the mysql site  UPDATE is expicity reserved in php 5.0

 

Now what this all means to me is nothing at this point as I am just starting the mysql and php tutorials. I just ran accross this while learning and posted.

 

I figured the list of reserved words for mysql was important so I even printed it out.

 

I don't remember what version or mysql the OP is using of if he even mentioned it. Godaddy offers 4.1 and 5.0 when setting up the databases. Also godaddy user name and database name are the same if that needs to be considered.

 

OK a reserved-word mean it has a use, so you can not use it as a field name, table, etc, unless you use backticks

 

ie

$sql="UPDATE $tbl_name SET comentario='$comentario' WHERE id='$id'";

is fine (trust me on that)

but

$sql="UPDATE $tbl_name SET UPDATE='$comentario' WHERE id='$id'";

would be wrong.. as UPDATE has a special meaning (thus its reserved), the the 2nd would confuse mySQL thus causing an error

I think I understand. Makes more sense.

 

So I am courious as to the progress on this issue, why I have no idea. I guess it is because I use godaddy alot, and if I run into something similar it will be good to know if it is a godaddy specific error.

 

Setting up some of my forums and other opens source stuff, I have run into php.ini problems.

about ?

as i said the that error isn't from that script..

 

about the error...the error isnt on the confi.php...because I can connect to the database etc....

 

the problem is in the script that updates the table on the database...I suppose.... ???

 

//// 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 'SET comentario='' WHERE id='0'' at line 1

 

about ?

as i said the that error isn't from that script..

 

about the error...the error isnt on the confi.php...because I can connect to the database etc....

 

the problem is in the script that updates the table on the database...I suppose.... ???

 

//// 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 'SET comentario='' WHERE id='0'' at line 1

 

 

Is there actually a record with the ID '0' since you're trying to UPDATE a record and not INSERT a record?

about ?

as i said the that error isn't from that script..

 

about the error...the error isnt on the confi.php...because I can connect to the database etc....

 

the problem is in the script that updates the table on the database...I suppose.... ???

 

//// 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 'SET comentario='' WHERE id='0'' at line 1

 

 

Is there actually a record with the ID '0' since you're trying to UPDATE a record and not INSERT a record?

 

no...

 

really I dont know what its causing this problem..I try everything...all looks ok....any more idea in what it could be?

I resolve the problem...

I just add this:

 

<?php

include"../config.php";

extract($_POST);

$sql = "UPDATE $tbl_name SET comentario='$comentario' WHERE id = '".$id."'";

$result=mysql_query($sql)or die(mysql_error());

if($result){

echo "<center>Cambio se realizo satifactoriamente.</center>";

echo "<BR>";

echo "<center><a href='../admin/viewvisitante.php'>Volver Atras</a><center>";

}

else {

echo "ERROR";

}

?>

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.