I have this: $sql = mysql_query("INSERT INTO games (id, name, category, width, height, type) VALUES('NULL', '$name', '$cat', '$w', '$h', '$type')") or die (mysql_error()); PHP: it works fine, but if i add ,desc to the first line and , '$desc' to the 2nd line, i get this error: Anyone know whats wrong? I have: $desc = $_POST['d']; <textarea rows="5" cols="20" name="d"></textarea>
yep, all spacing is correct. I swear ive looked at this for about an hour yesterday, and another hour today. I have absouletly no idea whats wrong, and its going to end up being something like that $sql = mysql_query("INSERT INTO games (id, name, category, width, height, type, desc) VALUES('NULL', '$name', '$cat', '$w', '$h', '$type', '$desc')") or die (mysql_error()); PHP:
Can you do this for me to try it? <textarea rows="5" cols="20" name="desc"></textarea> $desc = $_POST['desc]; $sql = mysql_query("INSERT INTO games (id, name, category, width, height, type, desc) VALUES('NULL', '$name', '$cat', '$w', '$h', '$type', '$desc')") or die (mysql_error()); Might be something with $_POST['variable'] not letting 1 character in.
nah, same thing.. plus i already have $name = $_POST['n']; $cat = $_POST['c']; $w = $_POST['w']; $h = $_POST['h']; $type = $_POST['t']; PHP:
It might be something to do with the fact that desc is a reserved word, i.e. has a special meaning of descending within an SQL statement. If you renamed desc to description in your code you probably won't have this issue. Rgds Accel
... Thanks, lol... I hate when its small things like that, and it takes forever to find. Should have known it. +rep to both.
As stated above, desc is a reserved word. You still can use it by placing it within a `` like: $sql = mysql_query("INSERT INTO `games` (`id`, `name`, `category`, `width`, `height`, `type`,`desc`) VALUES('NULL', '$name', '$cat', '$w', '$h', '$type','$desc')") or die (mysql_error()); PHP: But I wouldn't recommend it because when you transfer the database you won't be able to do it via softwares like phpMyAdmin. Another note, you should escape the desc and other text fields before adding them to mysql: $sql = mysql_query("INSERT INTO `games` (`id`, `name`, `category`, `width`, `height`, `type`,`desc`) VALUES('NULL', '".mysql_real_escape_string($name)."', '$cat', '$w', '$h', '$type','".mysql_real_escape_string($desc)."')") or die (mysql_error()); PHP: Spacing doesn't make a difference, you can have spaces or no spaces at all and it should work. Peace,