Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7613605
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T02:11:43+00:00 2026-05-31T02:11:43+00:00

I have a basic CMS where a user can update a database of articles

  • 0

I have a basic CMS where a user can update a database of articles and it uses a simple set of BBCodes for some extra features.

Basically, the user inputs the article information into a HTML form, and then on the click of a “Publish” button, an AJAX request is sent to a PHP script on the server which uses Regex to convert the BBCodes to HTML, and then stores the info in the database using MySQL.

My problem is an unfortunate one, in that it has come immediately after solving another, and it is very hard to debug since it is a server side script and I am getting no error messages echoed at all.

I was having trouble with the Regex, specifically with more complicated tags. I managed to get [link=URL]FOOBAR[/link] tags to correctly match and then replace them with FOOBAR. For some reason, however, this now made the script either hang or fail or something because I’m not getting anything updated into the database when it contains [link] tags.

For the purposes of debugging earlier when I wanted to get the SQL working, I had the PHP script echo the return value of the mysql_query() function which I believe is a “1” when it is successful, and a “0” when it fails. Now, however, it simply returns nothing… and the HTTPRequest receives a 0 length string back.

Here is the code:

$post = $_POST['post'];
$regex = Array('#(\r?\n)#', '#(\[(\/?)(b|i|u)\])#', '#\[link=(http://(www.)?.*?)\](.*?)\[/link\]#', '#(\[youtube\][http://www.youtube.com/watch?v=]?(\w+)[&\w+]?\[/youtube\])#', '#(\[img\](http://[www.]?[\w+])\[/img\])#');
$regReplace = Array('<br />', '<$2$3>', '<a href="$1">$3</a>', '<div class="media"><iframe title="YouTube video player" width="560" height="315" src="http://www.youtube.com/embed/$2" frameborder="0" allowfullscreen></iframe></div>',
                '<div class="media"><img width="560" src="$2" /></div>');
$post = preg_replace($regex, $regReplace, $post);
echo mysql_query('INSERT INTO News VALUES (NULL, "'.Date('D jS M').'", "'.Date('G:i').'", "'.$_POST['heading'].'", "'.$post.'")');

I am aware that the IMG and Youtube regexs don’t work…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T02:11:44+00:00Added an answer on May 31, 2026 at 2:11 am

    There are several issues here. The mentioned error stems from not escaping the quote in the parameter string with backslash + quote. Furthermore the SQL standard uses the single quote, so even if double quote is possible, it is better to use a single quote. And then there is a huge security leak, SQL injection, with which your site may be hacked (database and files displayed).

    Look at prepared statements which also solves the quote escaping.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a basic CRUD form that uses PageMethods to update the user details,
I have a basic CMS in PHP/MySQL where content managers can create pages to
I have a basic model in which i have specified some of the fields
I have gone through the N2 CMS documentation at length and can see no
I have a basic cms that loads content into pages that have mustache tags
I have been looking round for an open-source CMS framework that I can use
I have created a basic CMS using CodeIgniter 2.0.3, and now I want to
It is a basic HTML question. I have some div tags, which have some
I have basic markup for a drop down nav, nested lists. The user will
I'm designing a database in MySQL and PHP for a basic CMS. The CMS

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.