Jump to content

Recommended Posts

I have been looking at this code for 20mins and can't work out what I am doing wrong. There is something wrong with my sql statement below is the error and the code. what I am trying to do is to

edit some information that is already in the database

 

Any help would be great.

 

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 'active=1 content='dafasdsdfasgbvfgf gasd' at line 3

 

    private function insertq() {

        if  ( !empty($this->pageName) && !empty($this->position) && !empty($this->content) ) {
                                                echo $this->pageName ."   pn<br>";
                        echo $this->position ."   pos<br>";
                        echo $this->content."  con<br>";
                        echo $this->active."   act<br>";

                $query = "UPDATE webContent SET
                                      myOrder =$this->position
                                      active=$this->active 
                                      content='$this->content'
                                      WHERE pageName = '$this->pageName'";

                  if (mysql_query($query)) {
                      echo("<P>Your update has been added.</P>");
                  } else {
                      echo("<P>Error adding submitted update: " .
                          mysql_error() . "</P>");
                  }
                         

            }
        
        return $returnValue;

    }

Link to comment
https://forums.phpfreaks.com/topic/177453-solved-sql-error/
Share on other sites

Please change

echo("<P>Error adding submitted update: " .
                          mysql_error() . "</P>");

 

to

 

echo("<P>Error adding submitted update: " .
                          mysql_error() . ": $query</P>");

 

This will display full query string, so that we might look at it and try to find out what's wrong.

Link to comment
https://forums.phpfreaks.com/topic/177453-solved-sql-error/#findComment-935642
Share on other sites

I tried it with the commas still did not work. Below the following error came up with the change error handler

 

Error adding submitted update: 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 ' content='dafasdsdfasgbvfgf gasdasdfsdfsd' at line 3: UPDATE webContent SET myOrder =5, active= , content='dafasdsdfasgbvfgf gasdasdfsdfsdfsdf', WHERE pageName = 'ffdadfadfsadfsdfsdfas'

Link to comment
https://forums.phpfreaks.com/topic/177453-solved-sql-error/#findComment-935649
Share on other sites

yes I thought that to when I saw it but

 


Error adding submitted update: 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 'WHERE pageName = 'ffdadfadfsadfsdfsdfas'' at line 5: UPDATE webContent SET myOrder =5, active=1 , content='dafasdsdfasgbvfgf gasdasdfsdfsdfsdf', WHERE pageName = 'ffdadfadfsadfsdfsdfas'

Link to comment
https://forums.phpfreaks.com/topic/177453-solved-sql-error/#findComment-935665
Share on other sites

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.