Jump to content

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/165645-solved-php-mysql-error/
Share on other sites

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

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.

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')
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.