alexandre Posted January 23, 2023 Share Posted January 23, 2023 so i am trying to include the timer of the events in the user profile table and for some reason there is a number 1 appearing from nowhere but only if i include the whole countdown file if i just paste the code in my profile file it doesnt appear but i also cant get the timer to set a date. i would need to figure why this number one is spawning for no reasons since this is not even showing on the actual subscription page initially working with the subscription countdown file and everything is working well on this side.. this is just strange. <?php $stmt = $con->prepare("SELECT subscriptiondate, sub_status FROM subscriptions WHERE user_id = ?"); $stmt->bind_param('i', $_SESSION['id']); $stmt->bind_result($sub_date, $sub_status); $stmt->execute(); $stmt->fetch(); $stmt->close(); if (isset($sub_date)) { $subscription_time = $sub_date; } else if (!isset($sub_date)) { $subscription_time = '2022-11-05 23:59:59'; } $rem_time = $subscription_time; $target = $rem_time; // SET OR GET TARGET TIME HERE $targ = new DateTime($target); $target_time = $targ->format('g:ia'); $target_date = $targ->format('F jS Y'); $remain = ['days' => 0, 'hrs' => 0, 'mins' => 0, 'secs' => 0]; #$dt1 = new DateTime( $_GET['target'] ); $dt2 = new DateTime('now'); if ($targ > $dt2) { $diff = $targ->diff($dt2); $remain['days'] = $diff->days; $remain['hrs'] = $diff->h; $remain['mins'] = $diff->i; $remain['secs'] = $diff->s; } ?> <!DOCTYPE html> <html lang="en"> <head> <meta http-equiv="Content-Type" content="text/html charset='utf-8'"> <link rel="stylesheet" href="donation-clash.css" type="text/css"> <title>Countdown</title> </head> <body class="body4"> <div class="timerall"> <p class="p3">Countdown to</p> <p class='target'><?=$target_time?> on <?=$target_date?> </p> <table> <tr> <th>Days</th><th>Hours</th><th>Mins</th><th>secs</th> </tr> <tr> <td class='remain' id='days'><?=$remain['days']?></td> <td class='remain' id='hrs'><?=$remain['hrs']?></td> <td class='remain' id='mins'><?=$remain['mins']?></td> <td class='remain' id='secs'><?=$remain['secs']?></td> </tr> </table> </div> </body> </html> so this above is the countdown file for the subscription. <div> <p>registered to the:</p> <table> <tr> <th>Quicky event</th><th>Bronze event</th><th> Silver event</th><th>Golden event</th><th>Vip event</th><th class="sub_th">monthly Subscription</th> </tr> <tr> <td><?=$quicky_status?></td><td><?=$bronze_status?></td> <td><?=$silver_status?></td><td><?=$golden_status?></td><td><?=$vip_status?></td><td class="sub_th"><?=$subscription?></td> </tr> <tr> <td><?=$totalparticipant5?></td><td><?=$totalparticipant?></td><td><?=$totalparticipant2?></td><td><?=$totalparticipant3?></td><td><?=$totalparticipant4?></td><td class="sub_th"><?=include '../subscribe/sub_countdown.php'?></td> </tr> </table> </div> and this above is the part of the profile page including the countdown file. in the image you can clearly see under the timer that there is a 1 that should not be there. if anyone can find the cause of that , please let me know because it makes about 3 to 4 days that i am stuck on that ... Quote Link to comment https://forums.phpfreaks.com/topic/315829-need-help-to-figure-something/ Share on other sites More sharing options...
requinix Posted January 23, 2023 Share Posted January 23, 2023 <?=include '../subscribe/sub_countdown.php'?> include() returns a boolean. Quote Link to comment https://forums.phpfreaks.com/topic/315829-need-help-to-figure-something/#findComment-1604926 Share on other sites More sharing options...
alexandre Posted January 23, 2023 Author Share Posted January 23, 2023 (edited) for real? but why would it be appearing if i dont use a return for this exact boolean ? by that i mean that i have been using many includes and this is the first time it is returning a boolean. Edited January 23, 2023 by alexandre Quote Link to comment https://forums.phpfreaks.com/topic/315829-need-help-to-figure-something/#findComment-1604927 Share on other sites More sharing options...
requinix Posted January 23, 2023 Share Posted January 23, 2023 Look closer at what you have here <?=include '../subscribe/sub_countdown.php'?> and compare it to the other times you've done something similar. Quote Link to comment https://forums.phpfreaks.com/topic/315829-need-help-to-figure-something/#findComment-1604928 Share on other sites More sharing options...
alexandre Posted January 23, 2023 Author Share Posted January 23, 2023 i use the same method to display my paginations and it is not showing me any boolean result.. , is there something i dont know with the use of the include in a table ? because, to me i dont see any logical reasons , my paginations are also included in the html so there isnt much difference left that can be. in the include above , i didnt close the line inside the quotes with semi column or whatever is called the dot and coma , but once i did it didnt changed anything. Quote Link to comment https://forums.phpfreaks.com/topic/315829-need-help-to-figure-something/#findComment-1604930 Share on other sites More sharing options...
alexandre Posted January 23, 2023 Author Share Posted January 23, 2023 even on google it doesnt say anything about this.. should i be including the file in the php and filter the output to only display the timer and not the boolean? Quote Link to comment https://forums.phpfreaks.com/topic/315829-need-help-to-figure-something/#findComment-1604931 Share on other sites More sharing options...
requinix Posted January 23, 2023 Share Posted January 23, 2023 Post a sample of one of the times you did an include() that did not have this "1" problem. Quote Link to comment https://forums.phpfreaks.com/topic/315829-need-help-to-figure-something/#findComment-1604933 Share on other sites More sharing options...
alexandre Posted January 23, 2023 Author Share Posted January 23, 2023 (edited) thats strange ... i can see the number one everywhere now that i am aware of it 😂.. would you have a solution to this issue ? dos it count if it is included in the php part of the code because i just found that on the subscription page the countdown is included in the php and it doesnt show the boolean result. Edited January 23, 2023 by alexandre Quote Link to comment https://forums.phpfreaks.com/topic/315829-need-help-to-figure-something/#findComment-1604934 Share on other sites More sharing options...
alexandre Posted January 23, 2023 Author Share Posted January 23, 2023 (edited) i just realized that not long ago i switched my code , instead of only using php to do everything, i declared the variables in php to then output them in the html but as it was before only with php , it wasnt showing those number one Edited January 23, 2023 by alexandre Quote Link to comment https://forums.phpfreaks.com/topic/315829-need-help-to-figure-something/#findComment-1604935 Share on other sites More sharing options...
Solution requinix Posted January 23, 2023 Solution Share Posted January 23, 2023 I'll give this one more try: 1. I've already mentioned that include() will return a boolean. Specifically, true if it was able to include the file and false if it was not. 2. You are using <?= tags instead of regular <?php. Remind yourself of what the special <?= form does. Do you know what happens when you combine those two together? Quote Link to comment https://forums.phpfreaks.com/topic/315829-need-help-to-figure-something/#findComment-1604937 Share on other sites More sharing options...
alexandre Posted January 23, 2023 Author Share Posted January 23, 2023 i honestly dont know about that. i thought it was simply the way to include php into html but i should have noticed the difference between the normal php tags and the ones i am using . i will go look this up . thank you for specifying it. Quote Link to comment https://forums.phpfreaks.com/topic/315829-need-help-to-figure-something/#findComment-1604941 Share on other sites More sharing options...
alexandre Posted January 23, 2023 Author Share Posted January 23, 2023 it worked the number one disapeared as i changed the tag for the include .. when i am thinking that i just wasted 4 days being mad at my code 😂 Quote Link to comment https://forums.phpfreaks.com/topic/315829-need-help-to-figure-something/#findComment-1604942 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.