Jump to content
php.lv forumi

Nepareiza sintakse?


Sephy

Recommended Posts

Ar INSERT strada tadas vertibas, bet ar UPDATE SET nestrada, kur kļūda?

 

$insert = mysql_query("UPDATE news SET newsname = '".$_POST['title']."', SET newstext='".$_POST['add']."', SET address='".$_POST['address']."' WHERE newsname='$derp'") or die(mysql_error());

 

un 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 newstext='Ierakstiet raxta tekstu!t' at line 1

Link to comment
Share on other sites

if (isset($_POST['submit'])) {
$derp=$_POST['galerija'];
$derp= mysql_real_escape_string($derp);
//parbauda vai visilauki aizpilditi!
if (!$_POST['title'] | !$_POST['add'] | !$_POST['address'] ) {
echo('Aizpildiet visus laukus!');
}
$_POST['title'] = mysql_real_escape_string($_POST['title']);
$_POST['add'] = mysql_real_escape_string($_POST['add']);
$_POST['address'] = mysql_real_escape_string($_POST['address']);
$insert = mysql_query("UPDATE news SET newsname = '".$_POST['title']."', newstext='".$_POST['add']."', address='".$_POST['address']."' WHERE '$derp'=newsname") or die(mysql_error());
$add_member = mysql_query($insert);

Edited by Sephy
Link to comment
Share on other sites

Uztaisi

 

$data=array_map('mysql_real_escape_string',$_POST);

 

un $data tev saturēs visus POST datus eskeipotā veidā- varēsi lietot $data['title'];Protams labāk būtu uztaisīt query funkciju, kura automātiski eskeipo parametrus.

Edited by codez
Link to comment
Share on other sites

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.   Paste as plain text instead

  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.

Loading...
×
×
  • Create New...