I have a trouble with this code
Excuse my mixing of languages in this post... The inlagg table contens is as follow:
uid int(11) auto_increment primary key
artikel longtext
datum varchar(20)
keys varchar(200)
rubrik varchar(200)
kategori varchar(200)
n_dat int(11)
and the variables are comming in from a form. I think the trouble is somewhere close to $mtxt. First I thought it just was when I included a " in the text input but now it seems it's constant. I get an:
But I can't see why the query fails, not even after reentering it four times.
| Code: |
|
echo "My Code"; // Select and other things are correct $rub=mysql_real_escape_string($_POST['rubrik']); $mtxt=mysql_real_escape_string($_POST['txt']); $datum=date(Y)."-".date(m)."-".date(d); $katego=mysql_real_escape_string($_POST['kat']); $keyword=mysql_real_escape_string($_POST['keys']); $nuf_dat=date(Ymd); $query="INSERT INTO inlagg (rubrik,artikel,datum,kategori,keys,n_dat) VALUES ('".$rub."','".$mtxt."','".$datum."','".$katego."','".$keywords."','".$nuf_dat."');"; echo "<br />Detta kommer utföras: <br />".$query."<br />"; mysql_query($query) or die("Fel vid inmatning: <br />".mysql_error()); mysql_close(); |
Excuse my mixing of languages in this post... The inlagg table contens is as follow:
uid int(11) auto_increment primary key
artikel longtext
datum varchar(20)
keys varchar(200)
rubrik varchar(200)
kategori varchar(200)
n_dat int(11)
and the variables are comming in from a form. I think the trouble is somewhere close to $mtxt. First I thought it just was when I included a " in the text input but now it seems it's constant. I get an:
| mysql_error() wrote: |
|
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 'keys,n_dat) VALUES ('Testar utan länkar','Kommer sidan att skrivas in om ja' at line 1 |
But I can't see why the query fails, not even after reentering it four times.
