Jump to content

[SOLVED] CMS Problems


Simsonite

Recommended Posts

h i am trying to create a CMS for my website, however i am having problems with MySql Queries.

 

Here is the code

 

            <?php
            // Check whether a form has been submitted. If so, carry on
if ($HTTP_POST_VARS){

// Validate the entries
$validator = new Validator();

$validator->validateGeneral($HTTP_POST_VARS['thearticle'],'Article');

// Check whether the validator found any problems
if ( $validator->foundErrors() ){
echo 'There was a problem with: <br>'.$validator->listErrors('<br>'); // Show the errors, with a line between each
}else{

// Create an SQL query (MySQL version)
// The 'addslashes' command is used 5 lines below for added security
// Remember to use 'stripslashes' later to remove them (they are inserted in front of any
// special characters
$content = $HTTP_POST_VARS['thearticle'];
$insertQuery = "UPDATE 'cmscontent' SET thearticle='$content' WHERE ID = '1'";

// Save the form data into the database 
        //!!!!!!!!!!!!! THIS IS LINE 22!!!!!!!!!!!!!
if ($result = $connector->query(UPDATE 'cmscontent' SET 'thearticle'='$content' WHERE 'ID' = '1'));{

	// It worked, give confirmation
	echo '<center><b>Article added to the database</b></center><br>';

	else{

	// It hasn't worked so stop. Better error handling code would be good here!
	exit('<center>Sorry, there was an error saving to the database</center>');

}

}
}
?>
</div>
<form name="form1" method="post" action="editcontent.php" style="width:730px; margin-left:-4px;">
        <p align="center">
          <textarea name="thearticle" cols="50" rows="6" id="thearticle" class="mceEditor">
          <?php
           while ($row = $connector->fetchArray($oldcontent)){
               echo $row['thearticle'];
               }
           ?>
           </textarea>
        </p>
        <p align="center">
          <input type="submit" name="Submit" value="Submit">
        </p>
</form>

 

I am getting the error message Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /home/dancdoit/public_html/admin/cmsadmin/editcontent.php on line 122

Link to comment
https://forums.phpfreaks.com/topic/132484-solved-cms-problems/
Share on other sites

Well... show us line 122 of editcontent.php (and preferably some lines before)

 

As for line 22:

if ($result = $connector->query("UPDATE 'cmscontent' SET 'thearticle'='$content' WHERE 'ID' = '1'")){

 

There's unnecessary ; before { , AND you're missing "" around the query.

Link to comment
https://forums.phpfreaks.com/topic/132484-solved-cms-problems/#findComment-688860
Share on other sites

Ok thanks so much for helping me with the last problem.

 

However now i am trying to edit this script to delete content of the data base but it will not delete it.

 

this is the code

  <?php
// DELETE ARTICLES ////////////////////////////////////////////////////////////////////
if ($HTTP_GET_VARS['action'] == 'delete'){

    // Store the ID of the section to be deleted in a variable
    $sectionID = $HTTP_GET_VARS['ID'];

// Validate the section ID, and if it's ok then delete the section
if ( $validator->validateNumber($sectionID,'Section ID') ){

        // The validator returned true, so go ahead and delete the section
        $connector->query('DELETE FROM cmsarticles WHERE ID = '.$sectionID);

        echo 'Article Deleted <br><br>';

    }else{

        // The validator returned false, meaning there was a problem
        echo "Couldn't delete. There was a problem with: ".$validator->listErrors();

    }

}
// LIST ARTICLES /////////////////////////////////////////////////////////////////////
// Execute the query to retrieve articles
$result = $connector->query('SELECT ID,title,tagline FROM cmsarticles');

// Get an array containing the results.
// Loop for each item in that array
while ($row = $connector->fetchArray($result)){

echo '<br>';
    	echo "Title - {$row['title']}";
echo '<br>';
    	echo "Description - {$row['tagline']}";
echo '<br>';
    	echo '<a href="deletenews.php?action=delete&id='.$row['ID'].'"> Delete </a>';
echo '<br>';
echo '<br>';

}

?>

Link to comment
https://forums.phpfreaks.com/topic/132484-solved-cms-problems/#findComment-689513
Share on other sites

Ok thanks so much for helping me with the last problem.

 

However now i am trying to edit this script to delete content of the data base but it will not delete it.

Your last problem was a PHP issue... this maybe as well.

 

You need to check that you're actually getting into the block that deletes from the DB -- and that the query runs.

Link to comment
https://forums.phpfreaks.com/topic/132484-solved-cms-problems/#findComment-689623
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.