papillonstudios Posted July 11, 2009 Share Posted July 11, 2009 I have this wierd error, when i add 'desc' and '#desc' to this update code without it (works) <?php //Checks to see if theyre allowed to edit their profile if ($uCan['admin']) { //Double security incase the admin hasn't set a guest membergroup if ($uId) { //If the form hasn't been submitted, show it. if (!$_POST['submit']) { ?> <p><h3>Downlaod -> Add Download</h3></p> <br /> <form method="post"> <input type="hidden" name="username" value="<?php echo $uName;?>"> <table width="50%"> <tr><td>Name <?php echo form_input (text, name); ?></td></tr> <tr><td>URL <?php echo form_input (text, url); ?></td></tr> <tr><td></td></tr> <tr><td>Description <?php echo form_textarea (40, 10, desc); ?></td></tr> <tr><td><?php echo form_button (submit, submit, Post); ?></td></tr> </table> </form> <?php } //Or else it has been submitted... else { //Get information from the forms secure it all. $name = secure($_POST['name']); $username = secure($_POST['username']); $date = secure(date("Y/m/d")); $url = secure($_POST['url']); $desc = secure($_POST['desc']); $post = mysql_query("INSERT INTO `downloads` (name, username, date, url) VALUE ('$name', '$username', '$date', '$url')"); if ($post) echo 'The download has been added click <a href="index.php?action=dl">here</a>, to see it.'; else{ echo "Error message = ".mysql_error(); //A query to update everything } } } } ?> error follow Gaming_Fusion at http://twitter.com Error message = 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 'desc) VALUE ('Isus 2.0 Beta', 'admin', '2009/07/11', 'http://download.com/isus',' at line 1 code with 'desc' and '$desc' (doesn't work) follow Gaming_Fusion at http://twitter.com Error message = 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 'desc) VALUE ('Isus 2.0 Beta', 'admin', '2009/07/11', 'http://download.com/isus',' at line 1 Quote Link to comment https://forums.phpfreaks.com/topic/165645-solved-php-mysql-error/ Share on other sites More sharing options...
Andy-H Posted July 11, 2009 Share Posted July 11, 2009 desc is a mysql keyword (ie. ORDER BY fieldname DESC) and a bad choice of field name. If you wish to use a keyword in a query you must surround the word with `'s. e.g. `desc` Quote Link to comment https://forums.phpfreaks.com/topic/165645-solved-php-mysql-error/#findComment-873801 Share on other sites More sharing options...
papillonstudios Posted July 11, 2009 Author Share Posted July 11, 2009 thanks man i just changed it to dldesc Quote Link to comment https://forums.phpfreaks.com/topic/165645-solved-php-mysql-error/#findComment-873803 Share on other sites More sharing options...
papillonstudios Posted July 12, 2009 Author Share Posted July 12, 2009 WTF , i just tried to add another test download and it doesn't work i get this error. Error message = 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 '09', 'admin', '2009/07/11', 'http://apple.com/ilife', 'This is a download to the' at line 1 code: <?php //Checks to see if theyre allowed to edit their profile if ($uCan['admin']) { //Double security incase the admin hasn't set a guest membergroup if ($uId) { //If the form hasn't been submitted, show it. if (!$_POST['submit']) { ?> <p><h3>Downlaod -> Add Download</h3></p> <br /> <form method="post"> <input type="hidden" name="username" value="<?php echo $uName;?>"> <table width="50%"> <tr><td>Name <?php echo form_input (text, name); ?></td></tr> <tr><td>URL <?php echo form_input (text, url); ?></td></tr> <tr><td></td></tr> <tr><td>Description <?php echo form_textarea (40, 10, dldesc); ?></td></tr> <tr><td><?php echo form_button (submit, submit, Post); ?></td></tr> </table> </form> <?php } //Or else it has been submitted... else { //Get information from the forms secure it all. $name = secure($_POST['name']); $username = secure($_POST['username']); $date = secure(date("Y/m/d")); $url = secure($_POST['url']); $dldesc = secure($_POST['dldesc']); $post = mysql_query("INSERT INTO `downloads` (name, username, date, url, dldesc) VALUE ('$name', '$username', '$date', '$url', '$dldesc')"); if ($post) echo 'The download has been added click <a href="index.php?action=dl">here</a>, to see it.'; else{ echo "Error message = ".mysql_error(); //A query to update everything } } } } ?> *edit* I tried it again and for some reason if i use paragraph form so like Paragraph one. Blah blah blah blah Paragraph 2 . Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah but if i use a single it fine and in the database the column is set to the 'text' type Quote Link to comment https://forums.phpfreaks.com/topic/165645-solved-php-mysql-error/#findComment-873809 Share on other sites More sharing options...
Andy-H Posted July 12, 2009 Share Posted July 12, 2009 What does your "secure" function do? addSlashes()? nl2br()? Quote Link to comment https://forums.phpfreaks.com/topic/165645-solved-php-mysql-error/#findComment-873833 Share on other sites More sharing options...
Philip Posted July 12, 2009 Share Posted July 12, 2009 Change: $post = mysql_query("INSERT INTO `downloads` (name, username, date, url, dldesc) VALUE ('$name', '$username', '$date', '$url', '$dldesc')"); to: $q = "INSERT INTO `downloads` (name, username, date, url, dldesc) VALUE ('$name', '$username', '$date', '$url', '$dldesc')"; echo '<br>'.$q.'<br>'; $post = mysql_query($q); And copy/paste the query you're giving mysql. Quote Link to comment https://forums.phpfreaks.com/topic/165645-solved-php-mysql-error/#findComment-873835 Share on other sites More sharing options...
papillonstudios Posted July 12, 2009 Author Share Posted July 12, 2009 Change: $post = mysql_query("INSERT INTO `downloads` (name, username, date, url, dldesc) VALUE ('$name', '$username', '$date', '$url', '$dldesc')"); to: $q = "INSERT INTO `downloads` (name, username, date, url, dldesc) VALUE ('$name', '$username', '$date', '$url', '$dldesc')"; echo '<br>'.$q.'<br>'; $post = mysql_query($q); And copy/paste the query you're giving mysql. It worked that time and it gave me this INSERT INTO `downloads` (name, username, date, url, dldesc) VALUE ('Isus 2.0 Beta', 'admin', '2009/07/11', 'http;//isus.gamingfusion.net', 'The official Isus 2.0 Beta Release, check the link given for updated versions. *Test Download File *phpfreaks.com') Quote Link to comment https://forums.phpfreaks.com/topic/165645-solved-php-mysql-error/#findComment-873847 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.