Jump to content

roparzhhemon237

Members
  • Posts

    10
  • Joined

  • Last visited

roparzhhemon237's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Most blogs/forums I know (such as this one ) allow not only for the uploading and inclusion of images in a post (this I know how how to implement), but also the luxury of automatically inserting the image at the precise place the cursor was in the post when the user clicked the "image" icon in order to upload. This involves keeping track of the cursor’s whereabouts in a text field and I have no idea about how to do it with php or html. How is it done ? Where should I learn how to implement this in my made-from-scratch blog ?
  2. The manual says the format should be either 'YYYY-MM-DD HH:MM:SS' or YYYYMMDDHHMMSS. The format I get is just YYYY. For some (unknown to me) reason, only the first four character or digits are retained.
  3. I use this function everytime a new post is created in my forum. As all the posts are not posted at the same time, this looks reasonable to me.
  4. I’m translating some mixed PHP/MySQL code into pure MySQL code. Now I'm having a problem about how to translate PHP's time() function. I’m not sure how to choose between NOW(), CURDATE(), CURTIME(), and several others. I tried NOW(), but to my surprise it outputs today’s year (i.e. 2014) instead of the Unix integer timestamp I'm looking for. And this behaviour seems contray to the MySQL manual. What should I do ?
  5. Thank you for your helpful answer. Can I use this construct with UPDATE also ? E.g, can I write something like UPDATE post_table SET post_forum_id=(SELECT topic_forum_id FROM table_topic WHERE topic_id=2014) WHERE post_id=237; This looks like a real subquery this time.
  6. This sort of code is completely new to me. I understand SELECT acts a subquery in it ? Where is that construct explained in the MySQL manual ?
  7. I have following piece of code below, and I would like to be able to express it pure SQL, something that could go into a .sql file : $request_string='SELECT topic_forum_id FROM topic_table WHERE topic_id= 2014'; $query=database->prepare($request_string); $query->execute(); $data=$query->fetch(); $query->closeCursor(); $forum=$data['topic_forum_id']; $request_string='INSERT INTO post_table (post_topic,post_forum) VALUES (2014,:forum)'; $query=database->prepare($request_string); $query->bindValue(':forum',$forum,PDO::PARAM_INT); $query->execute(); $data=$query->fetch(); $query->closeCursor(); Is it possible ?
  8. Of course, how could I be so blind? Thanks for answering my stupid question.
  9. I’ve just read several manual pages and forum comments on "Error number 1064" but I still don’t understand what’s going on with the problem I'm having now … Also, I'm surprised that the error message mentions two different line numbers (1 and 35). Here is the error message I get : And here are the contents of my "one_more_visit_to_topic.php" file : <?php include("includes/model/database_searches/see_readings.php"); include("includes/model/database_searches/see_watchings.php"); function one_more_visit_to_topic($user_id,$topic_id) { global $db; $request_string='UPDATE forum_topic '. 'SET topic_vu = topic_vu + 1 WHERE topic_id = :topic'; $query=$db->prepare($request_string); $query->bindValue(':topic',$topic_id,PDO::PARAM_INT); $query->execute(); $query->CloseCursor(); // Remember that topic has been read by user if(!(see_if_user_has_read_topic($user_id,$topic_id))) { $request_string='INSERT INTO forum_read (fr_topic_id,fr_user_id) '. 'VALUES (:topic,:user)'; $query=$db->prepare($request_string); $query->bindValue(':topic',$topic_id,PDO::PARAM_INT); $query->bindValue(':user',$user_id,PDO::PARAM_INT); $query->execute(); $query->CloseCursor(); } // If user has already received a warning by mail, // the "alert" value needs to be toggled in the fw_watch table if(see_if_user_has_been_warned($user_id,$topic_id)) { $request_string='UPDATE forum_read SET fw_alert = :alt '. 'WHERE fw_topic_id = :topic AND fw_user_id= :user)'; $query=$db->prepare($request_string); $query->bindValue(':topic',$topic_id,PDO::PARAM_INT); $query->bindValue(':user',$user_id,PDO::PARAM_INT); $one=(int)1; $query->bindValue(':alt',$one,PDO::PARAM_INT); $query->execute(); $query->CloseCursor(); } return; } ?>
×
×
  • 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.