Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 04/23/2022 in all areas

  1. the most likely cause are the short opening <? tags, on lines 1 and 15 in the posted code and everywhere else they are used, being disabled. you can attempt to make this 'work' by enabling them in your php.ini the ideal way to fix this would be to do a search/replace to change all the <? tags, which must be followed by at least one white-space character (which isn't shown on line 15, but then again you didn't follow my instructions for posting the code), but not the <?= tags, into full <?php tags.
    1 point
  2. I'd define it something like this CREATE TABLE `comments` ( `post_id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(50) DEFAULT NULL, `datetime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `email` varchar(50) DEFAULT NULL, `comments` text, `approvedby` varchar(50) DEFAULT NULL, `status` tinyint(4) DEFAULT NULL, PRIMARY KEY (`post_id`) ) then, as stated earlier, datetime and post_id are generated automatically and can be excluded from the INSERT. As @ginerjm said, don't use varchar for dates. They should be DATE, DATETIME or TIMESTAMP and the format should be yyyy-mm-dd. Store them for functionality, not prettiness. Format them as required on output or in the query.
    1 point
  3. You don't want to create a field called 'datetime' as varchar. It s/b a DateTime type. $sql = "INSERT INTO comments (name, datetime, email, comments, approvedby, status, post_id) VALUES(:name, :email, :datetime, :comments, 'Pending', 'OFF', :post_id)"; Looking at your query statement do you see that you have mis-aligned fieldnames and values? You're trying to load an email into a datetime field and the reverse PS - I recommend switching to the array method of assigning the values instead of the tedious bind function as in this: $sql = "INSERT INTO comments(name,datetime,email,comments,approvedby,status,post_id)"; $sql .= "VALUES(:name,:email,:datetime,:comments,'Pending','OFF',:post_id)"; $parms = array( ':name'=>$name, ':datetime'=>$dt, ':email'=>$email, 'comments'=>$comments, ':post_id'=>$postid); if($sucess = $stmt->execute($parms)) {
    1 point
This leaderboard is set to New York/GMT-04:00
×
×
  • 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.