Oh no! Where's the JavaScript?
Your Web browser does not have JavaScript enabled or does not support JavaScript. Please enable JavaScript on your Web browser to properly view this Web site, or upgrade to a Web browser that does support JavaScript.
Sign In
Not a member yet? Click here to register.
Navigation

Need Code Confirmation

Last updated on 2 months ago
GrimlochGrimloch
Posted 2 months ago
Hi guys I'm back. If I could I would like to get a confirmation that my code as written will work correctly before I implement it:
This is from my create_post.php file in my new blog infusion.

$epoch = time();
$posted = $epoch;

$result = dbquery("INSERT INTO ".DB_GRIMS_BLOG_POST." (post_id, topic_id, post_title, post_body, post_img, post_thb, posted, active) VALUES ('', '$topic_id', '$post_title', '$post_body', '$post_img', '$post_thb', '$posted.', '$active')");
$last_id = LAST_INSERT_ID();
$month = date("m", posted);
$result = dbquery("INSERT INTO ".DB_GRIMS_BLOG_POST_TOPIC." (post_topic_id, post_id, topic_id, month) VALUES ('', '$last_id', '$topic_id', '$month')");


Any help/insights would be appreciated very much.
Edit: I went ahead and tried it and got an error: [24-Nov-2020 11:27:12 America/Chicago] PHP Fatal error:  Uncaught Error: Call to undefined function LAST_INSERT_ID() in /home/whisperw/public_html/infusions/grims_blog/admin/create_post.php:53
I don't understand why the error. I looked up how to get the last inserted id and thought that was it!

 
Edited by Grimloch on 24-11-2020 18:40, 2 months ago
RobiNNRobiNN
Posted 2 months ago
Use $last_id = dblastid()

This is really bad practice, why you don't save current timestamp ( time() function)? You can do many things with timestamp
$month = date("m", posted);

Why?
$epoch = time();
$posted = $epoch;

Use $posted = time();
GrimlochGrimloch
Posted 2 months ago
I've already changed $month = date("m", posted); to MONTH(CURDATE());
You're right; $epoch is just an old habit from previous infusions. I will change it. Thanks RobiNN.
GrimlochGrimloch
Posted 2 months ago
That's not it RobiNN. I still get a fatal error. It doesn't like dblastid(); either.
RobiNNRobiNN
Posted 2 months ago
Ah you use v8. dblastid() is for v9.

V8 for some reason has this name db_lastid()
You can view all discussion threads in this forum.
You cannot start a new discussion thread in this forum.
You cannot reply in this discussion thread.
You cannot start on a poll in this forum.
You cannot upload attachments in this forum.
You can download attachments in this forum.
You cannot up or down-vote on the post in this discussion thread.
You cannot set up a bounty in this discussion thread.
Moderator: Support Team
Users who participated in discussion: Grimloch, RobiNN,