PHP - A Php Error Was Encountered
Hi all trying to help a friend with a script his installing
but keep getting two errors
Severity: Warning
and
the code being run is
<?php $sql="SELECT * FROM `adminlogin` WHERE role='admin'"; $qry=mysqli_query($sql); $data=mysqli_fetch_array($qry); ?> not sure what I'm doing wrong any help would be appreciated
full page source is
<header id="header-navbar"> <div class="container" > <a style="background-color: #2a3133" href="<?php echo base_url();?>admin/dashboard" id="logo" class="navbar-brand"> <img src="<?php echo base_url();?>upload/taxi_logo.png" alt="" class="normal-logo logo-white" width="100%" height="100%"/> <!-- <img src="img/logo-black.png" alt="" class="normal-logo logo-black"/>--> <!-- <img src="img/logo-small.png" alt="" class="small-logo hidden-xs hidden-sm hidden"/>--> </a> <div class="clearfix"> <button class="navbar-toggle" data-target=".navbar-ex1-collapse" data-toggle="collapse" type="button"> <span class="sr-only">Toggle navigation</span> <span class="fa fa-bars"></span> </button> <div class="nav-no-collapse navbar-left pull-left hidden-sm hidden-xs"> <ul class="nav navbar-nav pull-left"> <li> <a class="btn" id="make-small-nav"> <i class="fa fa-bars"></i> </a> </li> <!-- <li class="dropdown hidden-xs">--> <!-- <a class="btn dropdown-toggle" data-toggle="dropdown">--> <!-- <i class="fa fa-bell"></i>--> <!-- <span class="count">8</span>--> <!-- </a>--> <!-- <ul class="dropdown-menu notifications-list">--> <!-- <li class="pointer">--> <!-- <div class="pointer-inner">--> <!-- <div class="arrow"></div>--> <!-- </div>--> <!-- </li>--> <!-- <li class="item-header">You have 6 new notifications</li>--> <!-- <li class="item">--> <!-- <a href="#">--> <!-- <i class="fa fa-comment"></i>--> <!-- <span class="content">New comment on ‘Awesome P...</span>--> <!-- <span class="time"><i class="fa fa-clock-o"></i>13 min.</span>--> <!-- </a>--> <!-- </li>--> <!-- <li class="item">--> <!-- <a href="#">--> <!-- <i class="fa fa-plus"></i>--> <!-- <span class="content">New user registration</span>--> <!-- <span class="time"><i class="fa fa-clock-o"></i>13 min.</span>--> <!-- </a>--> <!-- </li>--> <!-- <li class="item">--> <!-- <a href="#">--> <!-- <i class="fa fa-envelope"></i>--> <!-- <span class="content">New Message from George</span>--> <!-- <span class="time"><i class="fa fa-clock-o"></i>13 min.</span>--> <!-- </a>--> <!-- </li>--> <!-- <li class="item">--> <!-- <a href="#">--> <!-- <i class="fa fa-shopping-cart"></i>--> <!-- <span class="content">New purchase</span>--> <!-- <span class="time"><i class="fa fa-clock-o"></i>13 min.</span>--> <!-- </a>--> <!-- </li>--> <!-- <li class="item">--> <!-- <a href="#">--> <!-- <i class="fa fa-eye"></i>--> <!-- <span class="content">New order</span>--> <!-- <span class="time"><i class="fa fa-clock-o"></i>13 min.</span>--> <!-- </a>--> <!-- </li>--> <!-- <li class="item-footer">--> <!-- <a href="#">--> <!-- View all notifications--> <!-- </a>--> <!-- </li>--> <!-- </ul>--> <!-- </li>--> <!-- <li class="dropdown hidden-xs">--> <!-- <a class="btn dropdown-toggle" data-toggle="dropdown">--> <!-- <i class="fa fa-envelope-o"></i>--> <!-- <span class="count">16</span>--> <!-- </a>--> <!-- <ul class="dropdown-menu notifications-list messages-list">--> <!-- <li class="pointer">--> <!-- <div class="pointer-inner">--> <!-- <div class="arrow"></div>--> <!-- </div>--> <!-- </li>--> <!-- <li class="item first-item">--> <!-- <a href="#">--> <!-- <img src="img/samples/messages-photo-1.png" alt=""/>--> <!-- <span class="content">--> <!-- <span class="content-headline">--> <!-- George Clooney--> <!-- </span>--> <!-- <span class="content-text">--> <!-- Look, just because I don't be givin' no man a foot massage don't make it--> <!-- right for Marsellus to throw...--> <!-- </span>--> <!-- </span>--> <!-- <span class="time"><i class="fa fa-clock-o"></i>13 min.</span>--> <!-- </a>--> <!-- </li>--> <!-- <li class="item">--> <!-- <a href="#">--> <!-- <img src="img/samples/messages-photo-2.png" alt=""/>--> <!-- <span class="content">--> <!-- <span class="content-headline">--> <!-- Emma Watson--> <!-- </span>--> <!-- <span class="content-text">--> <!-- Look, just because I don't be givin' no man a foot massage don't make it--> <!-- right for Marsellus to throw...--> <!-- </span>--> <!-- </span>--> <!-- <span class="time"><i class="fa fa-clock-o"></i>13 min.</span>--> <!-- </a>--> <!-- </li>--> <!-- <li class="item">--> <!-- <a href="#">--> <!-- <img src="img/samples/messages-photo-3.png" alt=""/>--> <!-- <span class="content">--> <!-- <span class="content-headline">--> <!-- Robert Downey Jr.--> <!-- </span>--> <!-- <span class="content-text">--> <!-- Look, just because I don't be givin' no man a foot massage don't make it--> <!-- right for Marsellus to throw...--> <!-- </span>--> <!-- </span>--> <!-- <span class="time"><i class="fa fa-clock-o"></i>13 min.</span>--> <!-- </a>--> <!-- </li>--> <!-- <li class="item-footer">--> <!-- <a href="#">--> <!-- View all messages--> <!-- </a>--> <!-- </li>--> <!-- </ul>--> <!-- </li>--> <!-- <li class="dropdown hidden-xs">--> <!-- <a class="btn dropdown-toggle" data-toggle="dropdown">--> <!-- New Item--> <!-- <i class="fa fa-caret-down"></i>--> <!-- </a>--> <!-- <ul class="dropdown-menu">--> <!-- <li class="item">--> <!-- <a href="#">--> <!-- <i class="fa fa-archive"></i>--> <!-- New Product--> <!-- </a>--> <!-- </li>--> <!-- <li class="item">--> <!-- <a href="#">--> <!-- <i class="fa fa-shopping-cart"></i>--> <!-- New Order--> <!-- </a>--> <!-- </li>--> <!-- <li class="item">--> <!-- <a href="#">--> <!-- <i class="fa fa-sitemap"></i>--> <!-- New Category--> <!-- </a>--> <!-- </li>--> <!-- <li class="item">--> <!-- <a href="#">--> <!-- <i class="fa fa-file-text"></i>--> <!-- New Page--> <!-- </a>--> <!-- </li>--> <!-- </ul>--> <!-- </li>--> <!-- <li class="dropdown hidden-xs">--> <!-- <a class="btn dropdown-toggle" data-toggle="dropdown">--> <!-- English--> <!-- <i class="fa fa-caret-down"></i>--> <!-- </a>--> <!-- <ul class="dropdown-menu">--> <!-- <li class="item">--> <!-- <a href="#">--> <!-- Spanish--> <!-- </a>--> <!-- </li>--> <!-- <li class="item">--> <!-- <a href="#">--> <!-- German--> <!-- </a>--> <!-- </li>--> <!-- <li class="item">--> <!-- <a href="#">--> <!-- Italian--> <!-- </a>--> <!-- </li>--> <!-- </ul>--> <!-- </li>--> <!-- <span class="conveythis notranslate" translate="no"><a href="http://translation-services-usa.com/spanish.php" title="spanish translation services" class="conveythis-image conveythis-drop translate1">spanish translation services</a></span><script src="http://s1.conveythis.com/e4/javascript/e.js?conveythis_src=en"></script>--> </ul> </div> <div class="nav-no-collapse pull-right" id="header-nav"> <ul class="nav navbar-nav pull-right"> <li class="mobile-search"> <a class="btn"> <i class="fa fa-search"></i> </a> <div class="drowdown-search"> <form role="search"> <div class="form-group"> <input type="text" id="example1" class="form-control" placeholder="Search..."> <i class="fa fa-search nav-search-icon"></i> </div> </form> </div> </li> <?php $sql="SELECT * FROM `adminlogin` WHERE role='admin'"; $qry=mysqli_query($sql); $data=mysqli_fetch_array($qry); ?> <li class="dropdown profile-dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown"> <img src="<?php echo base_url().$data['image']; ?>" alt=""/> <span class="hidden-xs"><?php echo $data['username'];?></span> <b class="caret"></b> </a> <ul class="dropdown-menu dropdown-menu-right"> <li><a href="profile"><i class="fa fa-user"></i>Profile</a></li> <li><a href="password_change"><i class="fa fa-cog"></i>Change Password</a></li> <!-- <li><a href="#"><i class="fa fa-envelope-o"></i>Messages</a></li>--> <li><a href="logout"><i class="fa fa-power-off"></i>Logout</a></li> </ul> </li> <li class="hidden-xxs"> <a class="btn" href="logout"> <i class="fa fa-power-off"></i> </a> </li> </ul> </div> </div> </div> </header>
Similar TutorialsI am a new developer, trying to figure out what causing a memory error. The code goes through registered appointments and depends on the service ID, I have to free a 45 minutes for another service to be booked. Now, once I book an appointment for any of the services that can have 45 minutes free spot, the website takes forever to load the hours but doesn't show them, instead I get this error A PHP Error was encountered Severity: Error Message: Maximum execution time of 120 seconds exceeded
foreach ($appointments as $appointment) { foreach ($periods as $index => &$period) { $appointment_start = new DateTime($appointment['start_datetime']); $appointment_end = new DateTime($appointment['end_datetime']); if ($appointment_start >= $appointment_end) { continue; } $period_start = new DateTime($date . ' ' . $period['start']); $period_end = new DateTime($date . ' ' . $period['end']); $serviceId=$appointment['id_services']; $color1=1; $color2=2; $color3=3; $color4=4; $color5=5; $color6=6; $color7=7; $color8=8; $color9=9; $color10=10; $color11=11; $color12=12; $color13=13; $color14=14; $color15=15; $color16=16; $color17=17; $color18=18; $color19=19; $period_s=''; $period_e=''; if ($appointment_start <= $period_start && $appointment_end <= $period_end && $appointment_end <= $period_start) { // The appointment does not belong in this time period, so we will not change anything. continue; } else { if ($appointment_start <= $period_start && $appointment_end <= $period_end && $appointment_end >= $period_start) { // The appointment starts before the period and finishes somewhere inside. We will need to break // this period and leave the available part. //open slot for services 45,45,45 if($serviceId == $color1 || $serviceId == $color3 || $serviceId == $color7 || $serviceId == $color9|| $serviceId == $color10 || $serviceId == $color11 || $serviceId == $color12){ unset($periods[$index]); $period_s= clone $appointment_start; $period_s->modify('+45 minutes'); $period_e= clone $appointment_end; $period_e->modify('-45 minutes'); $periods[] = [ 'start' => $period_s->format('H:i'), 'end' =>$period_e->format('H:i') ]; $period['start'] = $appointment_end->format('H:i'); } //Open slot for service 45,45,60 else if($serviceId == $color2 || $serviceId == $color8){ $period_s= clone $appointment_start; $period_s->modify('+45 minutes'); $period_e= clone $appointment_end; $period_e->modify('-60 minutes'); $periods[] = [ 'start' => $period_s->format('H:i'), 'end' =>$period_e->format('H:i') ]; $period['start'] = $appointment_end->format('H:i'); } // // //Open slot for service 30,45,45 else if($serviceId == $color4 || $serviceId == $color6 ||$serviceId == $color16 || $serviceId == $color18){ $period_s= clone $appointment_start; $period_s->modify('+30 minutes'); $period_e= clone $appointment_end; $period_e->modify('-45 minutes'); $periods[] = [ 'start' => $period_s->format('H:i'), 'end' =>$period_e->format('H:i') ]; $period['start'] = $appointment_end->format('H:i'); } // // //Open slot for service 30,45,60 else if($serviceId == $color5 || $serviceId == $color17){ $period_s= clone $appointment_start; $period_s->modify('+30 minutes'); $period_e= clone $appointment_end; $period_e->modify('-60 minutes'); $periods[] = [ 'start' => $period_s->format('H:i'), 'end' =>$period_e->format('H:i') ]; $period['start'] = $appointment_end->format('H:i'); } // // //Open slot for service 60,45,45 else if($serviceId == $color13 || $serviceId == $color15){ $period_s= clone $appointment_start; $period_s->modify('+60 minutes'); $period_e= clone $appointment_end; $period_e->modify('-45 minutes'); $periods[] = [ 'start' => $period_s->format('H:i'), 'end' =>$period_e->format('H:i') ]; $period['start'] = $appointment_end->format('H:i'); } // // //Open slot for service 60,45,60 else if($serviceId == $color14 ){ $period_s= clone $appointment_start; $period_s->modify('+60 minutes'); $period_e= clone $appointment_end; $period_e->modify('-60 minutes'); $periods[] = [ 'start' => $period_s->format('H:i'), 'end' =>$period_e->format('H:i') ]; $period['start'] = $appointment_end->format('H:i'); } // //for the rest of services else { $period['start'] = $appointment_end->format('H:i');} } else { if ($appointment_start >= $period_start && $appointment_end < $period_end) { // The appointment is inside the time period, so we will split the period into two new // others. unset($periods[$index]); if($serviceId == $color1 || $serviceId == $color3 || $serviceId == $color7 || $serviceId == $color9|| $serviceId == $color10 || $serviceId == $color11 || $serviceId == $color12){ $period_s= clone $appointment_start; $period_s->modify('+45 minutes'); $period_e= clone $appointment_end; $period_e->modify('-45 minutes'); $periods[] = [ 'start' => $period_start->format('H:i'), 'end' => $appointment_start->format('H:i') ]; $periods[] = [ 'start' => $period_s->format('H:i'), 'end' =>$period_e->format('H:i') ]; $periods[] = [ 'start' => $appointment_end->format('H:i'), 'end' => $period_end->format('H:i') ]; } // //Open slot for service 45,45,60 else if($serviceId == $color2 || $serviceId == $color8){ $period_s= clone $appointment_start; $period_s->modify('+45 minutes'); $period_e= clone $appointment_end; $period_e->modify('-60 minutes'); $periods[] = [ 'start' => $period_start->format('H:i'), 'end' => $appointment_start->format('H:i') ]; $periods[] = [ 'start' => $period_s->format('H:i'), 'end' =>$period_e->format('H:i') ]; $periods[] = [ 'start' => $appointment_end->format('H:i'), 'end' => $period_end->format('H:i') ]; } // // //Open slot for service 30,45,45 else if($serviceId == $color4 || $serviceId == $color6 ||$serviceId == $color16 || $serviceId == $color18){ $period_s= clone $appointment_start; $period_s->modify('+30 minutes'); $period_e= clone $appointment_end; $period_e->modify('-45 minutes'); $periods[] = [ 'start' => $period_start->format('H:i'), 'end' => $appointment_start->format('H:i') ]; $periods[] = [ 'start' => $period_s->format('H:i'), 'end' =>$period_e->format('H:i') ]; $periods[] = [ 'start' => $appointment_end->format('H:i'), 'end' => $period_end->format('H:i') ]; } // // //Open slot for service 30,45,60 else if($serviceId == $color5 || $serviceId == $color17){ $period_s= clone $appointment_start; $period_s->modify('+30 minutes'); $period_e= clone $appointment_end; $period_e->modify('-60 minutes'); $periods[] = [ 'start' => $period_start->format('H:i'), 'end' => $appointment_start->format('H:i') ]; $periods[] = [ 'start' => $period_s->format('H:i'), 'end' =>$period_e->format('H:i') ]; $periods[] = [ 'start' => $appointment_end->format('H:i'), 'end' => $period_end->format('H:i') ]; } // // //Open slot for service 60,45,45 else if($serviceId == $color13 || $serviceId == $color15){ $period_s= clone $appointment_start; $period_s->modify('+60 minutes'); $period_e= clone $appointment_end; $period_e->modify('-45 minutes'); $periods[] = [ 'start' => $period_start->format('H:i'), 'end' => $appointment_start->format('H:i') ]; $periods[] = [ 'start' => $period_s->format('H:i'), 'end' =>$period_e->format('H:i') ]; $periods[] = [ 'start' => $appointment_end->format('H:i'), 'end' => $period_end->format('H:i') ]; } // // //Open slot for service 60,45,60 else if($serviceId == $color14 ){ $period_s= clone $appointment_start; $period_s->modify('+60 minutes'); $period_e= clone $appointment_end; $period_e->modify('-60 minutes'); $periods[] = [ 'start' => $period_start->format('H:i'), 'end' => $appointment_start->format('H:i') ]; $periods[] = [ 'start' => $period_s->format('H:i'), 'end' =>$period_e->format('H:i') ]; $periods[] = [ 'start' => $appointment_end->format('H:i'), 'end' => $period_end->format('H:i') ]; } //for other services once The code is completely correct else{ $periods[] = [ 'start' => $period_start->format('H:i'), 'end' => $appointment_start->format('H:i') ]; $periods[] = [ 'start' => $appointment_end->format('H:i'), 'end' => $period_end->format('H:i') ]; } } else if ($appointment_start == $period_start && $appointment_end == $period_end) { if($serviceId == $color1 || $serviceId == $color3 || $serviceId == $color7 || $serviceId == $color9|| $serviceId == $color10 || $serviceId == $color11 || $serviceId == $color12){ unset($periods[$index]); $period_s= $appointment_start; $period_s->modify('+45 minutes'); $period_e= $appointment_end; $period_e->modify('-45 minutes'); $periods[] = [ 'start' => $period_s->format('H:i'), 'end' =>$period_e->format('H:i') ]; } //Open slot for service 45,45,60 else if($serviceId == $color2 || $serviceId == $color8){ unset($periods[$index]); $period_s= clone $appointment_start; $period_s->modify('+45 minutes'); $period_e= clone $appointment_end; $period_e->modify('-60 minutes'); $periods[] = [ 'start' => $period_s->format('H:i'), 'end' =>$period_e->format('H:i') ]; } // // //Open slot for service 30,45,45 else if($serviceId == $color4 || $serviceId == $color6 ||$serviceId == $color16 || $serviceId == $color18){ unset($periods[$index]); $period_s= clone $appointment_start; $period_s->modify('+30 minutes'); $period_e= clone $appointment_end; $period_e->modify('-45 minutes'); $periods[] = [ 'start' => $period_s->format('H:i'), 'end' =>$period_e->format('H:i') ]; } // // //Open slot for service 30,45,60 else if($serviceId == $color5 || $serviceId == $color17){ unset($periods[$index]); $period_s= clone $appointment_start; $period_s->modify('+30 minutes'); $period_e= clone $appointment_end; $period_e->modify('-60 minutes'); $periods[] = [ 'start' => $period_s->format('H:i'), 'end' =>$period_e->format('H:i') ]; } // // //Open slot for service 60,45,45 else if($serviceId == $color13 || $serviceId == $color15){ unset($periods[$index]); $period_s= clone $appointment_start; $period_s->modify('+60 minutes'); $period_e= clone $appointment_end; $period_e->modify('-45 minutes'); $periods[] = [ 'start' => $period_s->format('H:i'), 'end' =>$period_e->format('H:i') ]; } // // //Open slot for service 60,45,60 else if($serviceId == $color14 ){ unset($periods[$index]); $period_s= clone $appointment_start; $period_s->modify('+60 minutes'); $period_e= clone $appointment_end; $period_e->modify('-60 minutes'); $periods[] = [ 'start' => $period_s->format('H:i'), 'end' =>$period_e->format('H:i') ];} // //for the rest of services else { unset($periods[$index]);} // The whole period is blocked so remove it from the available periods array. } else { if ($appointment_start >= $period_start && $appointment_end >= $period_start && $appointment_start <= $period_end) { // The appointment starts in the period and finishes out of it. We will need to remove //the time that is taken from the appointment. if($serviceId == $color1 || $serviceId == $color3 || $serviceId == $color7 || $serviceId == $color9|| $serviceId == $color10 || $serviceId == $color11 || $serviceId == $color12){ unset($periods[$index]); $period_s= clone $appointment_start; $period_s->modify('+45 minutes'); $period_e= clone $appointment_end; $period_e->modify('-45 minutes'); $period['end'] = $appointment_start->format('H:i'); $periods[] = [ 'start' => $period_s->format('H:i'), 'end' =>$period_e->format('H:i') ]; } //Open slot for service 45,45,60 else if($serviceId == $color2 || $serviceId == $color8){ $period_s= clone $appointment_start; $period_s->modify('+45 minutes'); $period_e= clone $appointment_end; $period_e->modify('-60 minutes'); $period['end'] = $appointment_start->format('H:i'); $periods[] = [ 'start' => $period_s->format('H:i'), 'end' =>$period_e->format('H:i') ]; } // // //Open slot for service 30,45,45 else if($serviceId == $color4 || $serviceId == $color6 ||$serviceId == $color16 || $serviceId == $color18){ $period_s= clone $appointment_start; $period_s->modify('+30 minutes'); $period_e= clone $appointment_end; $period_e->modify('-45 minutes'); $periods[] = [ 'start' => $period_s->format('H:i'), 'end' =>$period_e->format('H:i') ]; $period['end'] = $appointment_start->format('H:i'); } // // //Open slot for service 30,45,60 else if($serviceId == $color5 || $serviceId == $color17){ $period_s= clone $appointment_start; $period_s->modify('+30 minutes'); $period_e= clone $appointment_end; $period_e->modify('-60 minutes'); $periods[] = [ 'start' => $period_s->format('H:i'), 'end' =>$period_e->format('H:i') ]; $period['end'] = $appointment_start->format('H:i'); } // // //Open slot for service 60,45,45 else if($serviceId == $color13 || $serviceId == $color15){ $period_s= clone $appointment_start; $period_s->modify('+60 minutes'); $period_e= clone $appointment_end; $period_e->modify('-45 minutes'); $periods[] = [ 'start' => $period_s->format('H:i'), 'end' =>$period_e->format('H:i') ]; $period['end'] = $appointment_start->format('H:i'); } // // //Open slot for service 60,45,60 else if($serviceId == $color14 ){ $period_s= clone $appointment_start; $period_s->modify('+60 minutes'); $period_e= clone $appointment_end; $period_e->modify('-60 minutes'); $periods[] = [ 'start' => $period_s->format('H:i'), 'end' =>$period_e->format('H:i') ]; $period['end'] = $appointment_start->format('H:i'); } // for the rest of services else{ $period['end'] = $appointment_start->format('H:i'); } } else { if ($appointment_start >= $period_start && $appointment_end >= $period_end && $appointment_start >= $period_end) { // The appointment does not belong in the period so do not change anything. continue; } else { if ($appointment_start <= $period_start && $appointment_end >= $period_end && $appointment_start <= $period_end) { //Open slot for service 45,45,45 if($serviceId == $color1 || $serviceId == $color3 || $serviceId == $color7 || $serviceId == $color9|| $serviceId == $color10 || $serviceId == $color11 || $serviceId == $color12){ unset($periods[$index]); $period_s= clone $appointment_start; $period_s->modify('+45 minutes'); $period_e= clone $appointment_end; $period_e->modify('-45 minutes'); $periods[] = [ 'start' => $period_s->format('H:i'), 'end' =>$period_e->format('H:i') ]; } //Open slot for service 45,45,60 else if($serviceId == $color2 || $serviceId == $color8){ unset($periods[$index]); $period_s= clone $appointment_start; $period_s->modify('+45 minutes'); $period_e= clone $appointment_end; $period_e->modify('-60 minutes'); $periods[] = [ 'start' => $period_s->format('H:i'), 'end' =>$period_e->format('H:i') ]; } // //Open slot for service 30,45,45 else if($serviceId == $color4 || $serviceId == $color6 ||$serviceId == $color16 || $serviceId == $color18){ unset($periods[$index]); $period_s= clone $appointment_start; $period_s->modify('+30 minutes'); $period_e= clone $appointment_end; $period_e->modify('-45 minutes'); $periods[] = [ 'start' => $period_s->format('H:i'), 'end' =>$period_e->format('H:i') ];} //Open slot for service 30,45,60 else if($serviceId == $color5 || $serviceId == $color17){ unset($periods[$index]); $period_s= clone $appointment_start; $period_s->modify('+30 minutes'); $period_e= clone $appointment_end; $period_e->modify('-60 minutes'); $periods[] = [ 'start' => $period_s->format('H:i'), 'end' =>$period_e->format('H:i') ];} // // //Open slot for service 60,45,45 else if($serviceId == $color13 || $serviceId == $color15){ unset($periods[$index]); $period_s= clone $appointment_start; $period_s->modify('+60 minutes'); $period_e= clone $appointment_end; $period_e->modify('-45 minutes'); $periods[] = [ 'start' => $period_s->format('H:i'), 'end' =>$period_e->format('H:i') ];} // // //Open slot for service 60,45,60 else if($serviceId == $color14 ){ unset($periods[$index]); $period_s= clone $appointment_start; $period_s->modify('+60 minutes'); $period_e= clone $appointment_end; $period_e->modify('-60 minutes'); $periods[] = [ 'start' => $period_s->format('H:i'), 'end' =>$period_e->format('H:i') ];} else{ unset($periods[$index]); } } } } } } } } } return array_values($periods); } This topic has been moved to Apache HTTP Server. http://www.phpfreaks.com/forums/index.php?topic=343321.0 I am getting this error on my sales cart page. I am editting a PHP Point of sale program. Cant work out why this is not working. It should display the amount of points the item is worth. Help please Heres the error im getting: A PHP Error was encountered Severity: Notice Message: Undefined index: points Filename: sales/register.php Line Number: 69 Heres the code: <div class='warning_message' style='padding:7px;'><?php echo $this->lang->line('sales_no_items_in_cart'); ?></div> </tr></tr> <?php } else { foreach($cart as $item_id=>$item) { echo form_open("sales/edit_item/$item_id"); ?> <tr> <td><?php echo anchor("sales/delete_item/$item_id",'['.$this->lang->line('common_delete').']');?></td> <td><?php echo $item['name']; ?></td> !!!THIS IS LINE 69 !!! <td><?php echo $item['points']; ?></td> <?php if ($items_module_allowed) { ?> <td><?php echo form_input(array('name'=>'price','value'=>$item['price'],'size'=>'6'));?></td> <?php } else { ?> <td><?php echo $item['price']; ?></td> <?php echo form_hidden('price',$item['price']); ?> <?php } ?> <td><?php echo form_input(array('name'=>'quantity','value'=>$item['quantity'],'size'=>'2'));?></td> <td><?php echo form_input(array('name'=>'discount','value'=>$item['discount'],'size'=>'3'));?></td> <td><?php echo to_currency($item['price']*$item['quantity']-$item['price']*$item['quantity']*$item['discount']/100); ?></td> <td><?php echo form_submit("edit_item", $this->lang->line('sales_edit_item'));?></td> </tr> </form> Any ideas?
Morning !
I've tried a number of things but not able to sort out the error ..anyone see why I am getting the non well formed numeric error?
TIA
Is there any way to disable the "A non-numeric value encountered" warning in the php.ini file? I don't get that warning on my Apache server but I do when I use the same code on my web host's server. I never got the warning until I uploaded a two line php.ini file to my web host so that I could keep my sessions longer than the default 24 minutes. This is the same online program related to my earlier post about too many inputs. I wanted to try sessions for a 24 hr. period but I'm getting tons of errors for any field that is not used which can be in the hundreds. If I delete my php.ini file from my web host & just let things default to whatever they are using then I don't get those errors, I have three files: Quote /index.php /include/index.php /include/ajax.php the /index.php page is the landing page, which includes the file /include/index.php once the page loads, I make ajax calls to /include/ajax.php here is what the files basically looks like: index.php <html><body><? include('include/index.php'); ?></body></html> include/index.php <? session_start() unset($_SESSION['team']); $_SESSION['team'] = '9'; include/ajax.php <? session_start() $_SESSION['team'] = $_SESSION['team'] . ',9'; Pretty simple right? However, here is what is happening, every time I make a call ajax call to /include/ajax.php, the code in /include/index.php also gets executed and team is reset to 9! I am using jquery to make the ajax call: Code: [Select] $("input:radio").live('click', function() { $.ajax( { url:'include/ajax.php', success: function (data) { alert('done'); } }); }); and when I view the value after each ajax call, it is set to just 9. This is not any other issue, other than the code in include/index.php being executed each time the ajax function is called. Why in the world is the code in include/index.php being execute?! Under what circumstance would such a thing occur? ok what in the world is going on here... I have a simple javascript code to switch out the text between a div there are 4 rotations the text that is being switched is populated from my DB using php. now the weird part. in my DB i'm using longtext now If the text in the db is all one paragraph everything works fine but if there is any type of line break or new paragraph the script wont rotate at all. any ideas? Hi, After making an update, I have received this notice: Notice: A non well formed numeric value encountered in -... -on different page on line 128 : <?php $identifier = round(microtime() * 10000000); ?> on line 402 : <?php $identifier = round(microtime() * 10000000); ?> on line 2: <?php $identifier = round(microtime() * 10000000); ?>
How can I fix it? Thanks so much Federica Hi, My errorlog keep spamming the following errormsg: "PHP Notice: A non well formed numeric value encountered on line 365". This is the code it refers to: Code: [Select] for ($yr = $year, $age = -1; mktime(0, 0, 0, $month, $day, (int)$yr) < $today; $yr++, $age++); It's supposed to calculate the owner of the page's age. The full code is: Code: [Select] list($year,$month,$day) = explode("-", $birthday); $tempVar=list($year,$month,$day) = explode("-", $birthday); $today = time(); for ($yr = $year, $age = -1; mktime(0, 0, 0, $month, $day, (int)$yr) < $today; $yr++ I have a huge application(multi-year) where I do the normal $varX= $var1 + $var2. I get Warning: A non-numeric value encountered because var1 or var 2 are string. I know the right thing will be to intval(), but I just cant go over so much of the application. I read to just disable warning, but I think thats worst because I will not be able to see new warnings. Is there any php.ini solution were php can work as before on math operations? I guess I can ini_set on all the old files and dont do it on the new ones). If there is another accepted solution, please let me know Thank you
Hello all,
Appreciate if you folks could pls. help me understand (and more importantly resolve) this very weird error:
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ASC, purchase_later_flag ASC, shopper1_buy_flag AS' at line 3' in /var/www/index.php:67 Stack trace: #0 /var/www/index.php(67): PDO->query('SELECT shoplist...') #1 {main} thrown in /var/www/index.php on line 67
Everything seems to work fine when/if I use the following SQL query (which can also be seen commented out in my code towards the end of this post) :
$sql = "SELECT shoplist.*, store_master.store_name, item_master.item_name FROM shoplist, store_master, item_master WHERE shoplist.store_id = store_master.store_id AND shoplist.item_id = item_master.item_id";However, the moment I change my query to the following, which essentially just includes/adds the ORDER BY clause, I receive the error quoted above: $sql = "SELECT shoplist.*, store_master.store_name, item_master.item_name FROM shoplist, store_master, item_master ORDER BY purchased_flag ASC, purchase_later_flag ASC, shopper1_buy_flag ASC, shopper2_buy_flag ASC, store_name ASC) WHERE shoplist.store_id = store_master.store_id AND shoplist.item_id = item_master.item_id";In googling for this error I came across posts that suggested using "ORDER BY FIND_IN_SET()" and "ORDER BY FIELD()"...both of which I tried with no success. Here's the portion of my code which seems to have a problem, and line # 67 is the 3rd from bottom (third last) statement in the code below: <?php /* $sql = "SELECT shoplist.*, store_master.store_name, item_master.item_name FROM shoplist, store_master, item_master WHERE shoplist.store_id = store_master.store_id AND shoplist.item_id = item_master.item_id"; */ $sql = "SELECT shoplist.*, store_master.store_name, item_master.item_name FROM shoplist, store_master, item_master ORDER BY FIND_IN_SET(purchased_flag ASC, purchase_later_flag ASC, shopper1_buy_flag ASC, shopper2_buy_flag ASC, store_name ASC) WHERE shoplist.store_id = store_master.store_id AND shoplist.item_id = item_master.item_id"; $result = $pdo->query($sql); // foreach ($pdo->query($sql) as $row) { foreach ($result as $row) { echo '<tr>'; print '<td><span class="filler-checkbox"><input type="checkbox" name="IDnumber[]" value="' . $row["idnumber"] . '" /></span></td>';Thanks Parse error: syntax error, unexpected T_STRING in C:\xampp\htdocs\mywork\unique.php on line 15 <html> <head> <title> </title> </head> <body bgproperties="fixed"> <?php $dbhost = 'localhost'; $dbuser = 'root'; $dbpass = ''; $con = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql'); $dbname = 'mywork'; mysql_select_db($dbname, $con); $sql=mysql_query(insert into users (regno,name,gender,date,month,year,emailid,cell,paddress,caddress,incometype,incomeamt,dad,fyes,dadocup,mom,myes,momocup,password) VALUES ('$_POST[regno]','$_POST[name]','$_POST[gender]','$_POST[date]','$_POST[month]','$_POST[year]','$_POST[emailid]','$_POST[cell]','$_POST[paddress]','$_POST[caddress]','$_POST[incometype]','$_POST[incomeamt]','$_POST[dad]','$_POST[fyes]','$_POST[dadocup]','$_POST[mom]','$_POST[myes]','$_POST[momocup]','$_POST[password]')"); $sql1=mysql_fetch_array($sql); $result = @mysql_query($SQl1); $result="SELECT * FROM users WHERE regno='$regno'"; while($row = mysql_fetch_array($result)) { //echo $row['regno']."regno<br>"; //echo $row['name']."name<br>"; //echo $row['gender']."gender<br>"; //echo $row['date']."date<br>"; //echo $row['month']."month<br>"; //echo $row['year']."year<br>"; //echo $row['emailid']."emailid<br>"; //echo $row['cell']."cell<br>"; //echo $row['paddress']."paddress<br>"; //echo $row['caddress']."caddress<br>"; //echo $row['incometype']."incometype<br>"; //echo $row['incomeamt']."incomeamt<br>"; //echo $row['dad']."dad<br>"; //echo $row['fyes']."fyes<br>"; //echo $row['dadocup']."dadocup<br>"; //echo $row['mom']."mom<br>"; //echo $row['myes']."myes<br>"; //echo $row['momocup']."momocup<br>"; //echo $row['password']."password<br>"; } echo "Thanks for Register!"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } echo "1 record added"; mysql_close($con); ?> <form name="security" action="index.php" method="post"> <input type="submit" value="click here to login"> </form> </body> </html> Code: [Select] <?php mysql_connect ("-","-","-") or die ('Error'); mysql_select_db ("-"); $out = mysql_query("SELECT * FROM guestbook ORDER BY id DESC"); while($row = mysql_fetch_assoc($out); --and this one if that braces is deleted { ----this is where im getting the error $name = $row['name']; $email = $row['email']; $txt = $row['comment']; $msg = "Are you sure you want to delete"; /* @var $_REQUEST <type> */ if (isset($_REQUEST ["action"]) && $_REQUEST["action"] == "del") { $id = intval($_REQUEST['id']); mysql_query("DELETE FROM guestbook WHERE id=$id;"); echo "<action=index.php>"; } echo "<font face='verdana' size='1'>"; echo "<table border='0'> <tr><td>Name: ".$name."</td></tr>"." <tr><td>Email: ".$email."</td></tr> <tr><td colspan='2'>Comment:</td></tr> <tr><td colspan='2' width='500'><b>".$txt."</b></td></tr> <tr><td><a onclick=\"return confirm('.$msg.');\" href='index.php?action=del&id=".$row['id']."'><span class='red'>["."Delete"."]</span></a> </td></tr> </table><br />"; echo "<hr size='1' width='500' align='left'></font>"; } ?> Kindly help me please. When i delete ({) the error will become the ( i dont know what to do already. Thanks. $BoxSize = array("smallbox" = array("length" => 12, "width" => 10, "depth" => 2.5), "mediumbox" = array("length" => 30, "width" => 20, "depth" => 4), "largebox" = array("length" => 60, "width" => 40, "depth" => 11.5)); I just enabled error reporting and I am not that familiar with it. I know I have an error some where around line 33. I know I am missing a bracket or a comma or some other syntax error I just cannot find where the error is. Below is my script. Thanks for any help. Code: [Select] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Airline Survey</title> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" /> <meta name="author" content="Revised by abc1234"/> </head> <body> <?php $WaitTime = addslashes($_POST["wait_time"]); $Friendliness = addslashes($_POST["friendliness"]); $Space = addslashes($_POST["space"]); $Comfort = addslashes($_POST["comfort"]); $Cleanliness = addslashes($_POST["cleanliness"]); $Noise = addslashes($_POST["noise"]); if (empty($WaitTime) || empty($Friendliness) || empty($Space) || empty($Comfort) || empty($Cleanliness) || empty($Noise)) echo "<hr /><p>You must enter a value in each field. Click your browser's Back button to return to the form.</p><hr />"; else { $Entry = $WaitTime . "\n"; $Entry .= $Friendliness . "\n"; $Entry .= $Space . "\n"; $Entry .= $Comfort . "\n"; $Entry .= $Cleanliness . "\n"; $Entry .= $Noise . "\n"; $SurveyFile = fopen("survey.txt", "w") } if (flock($SurveyFile, LOCK_EX)) { if (fwrite($SurveyFile, $Entry) > 0) { echo "<p>The entry has been successfully added.</p>"; flock($SurveyFile, LOCK_UN; fclose($SurveyFile); else echo "<p>The entry could not be saved!</p>"; } else echo "<p>The entry could not be saved!</p>"; } ?d> <p><a href="AirlineSurvey.html">Return to Airline Survey</a></p> </body> </html> Hi folks, I am a complete n00b at php and mysql. I am teaching myself from books and the WWW, but alas I am stuck... the error I get is: Parse error: syntax error, unexpected T_STRING in X:\xampp\htdocs\search.php on line 7 here is the code: <?php mysql_connect ("localhost", "user", "password") or die (mysql_error()); mysql_select_db ("it_homehelp_test") or die (mysql_error()); $term = $_POST['term']; $sql = $mysql_query(select * from it_homehelp_test where ClientName1 like '%term%'); <<<------this is line 7 while ($row = mysql_fetch_array($sql)){ echo 'Client Name:' .$row['ClientName1']; echo 'Address:' .$row['Address1']; echo 'Phone:' .$row['Tel1']; } ?> Any help you can offer would be great. I can also post the ".html" file that creates the search bar if it is needed. Thanks I don`t get it, waht is wrong?! Code: [Select] <?php require_once 'auth.php'; if (!isset($_SESSION['SESS_VERIFY'])) { header("location: access-denied.php"); exit(); } if ($_SESSION['lang'] == 'Ro') { // setare data romania date_default_timezone_set('Europe/Bucharest'); $today = getdate(); $zi = $today['mday']; $luna = $today['mon']; $lunastring = $today['month']; $an = $today['year']; $data = $zi.$luna.$an; $data = (string)$data; $ora = date('H:i:s'); $msg = array(); $err = array(); $luni = array ( 1=>'Ianuarie', 2=>'Februarie', 3=>'Martie', 4=>'Aprilie', 5=>'Mai', 6=>'Iunie', 7=>'Iulie', 8=>'August', 9=>'Septembrie', 10=>'Octobrie', 11=>'Noiembrie', 12=>'Decembrie'); // comun const SQL_ERR = 'SQL statement failed with error: '; const ADD_MODEL = 'ADAUGA UN MODEL NOU'; . .many constants.. . } elseif ($_SESSION['lang'] == 'It') {... Thank you!
Hello everyone,
1 <?php
7 // Create connection
10 // Check connection
14 $firstname = $conn->real_escape_string($_REQUEST['firstname']); 25 $sql2 = "INSERT INTO countries VALUES ('$country')"; 27 $sql3 = "INSERT INTO Contacts (firstname, lastname, address, city, country, phone, email) VALUES ('$firstname', '$lastname', '$address', $city, $country, '$phone_number','$email')";
29 SELECT * FROM cities;
if($conn->query($sql2) === true){
if($conn->query($sql3) === true){ |