PHP - Weirdest Problem Ive Encountered..
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? Similar TutorialsHello, I have this script that converts my unixtimestamp into "XXXX Ago" time format. Code: [Select] function timeAgo($tm,$rcs = 0) { $cur_tm = time(); $dif = $cur_tm-$tm; $pds = array('second','minute','hour','day','week','month','year','decade'); $lngh = array(1,60,3600,86400,604800,2630880,31570560,315705600); for($v = sizeof($lngh)-1; ($v >= 0)&&(($no = $dif/$lngh[$v])<=1); $v--); if($v < 0) $v = 0; $_tm = $cur_tm-($dif%$lngh[$v]); $no = floor($no); if($no <> 1) $pds[$v] .='s'; $x=sprintf("%d %s ",$no,$pds[$v]); if(($rcs > 0)&&($v >= 1)&&(($cur_tm-$_tm) > 0)) $x .= timeAgo($_tm, --$rcs); return $x; } This is how I use the script on my forum script/site. Code: [Select] timeAgo($member['last_activity'])$member['last_activity'] is a unix Timestamp. This works wonderful! but here's the problem! I am trying to make it go 2 levels more. Like instead of just "2 Minutes ago" It says: 2 Minutes 20 seconds ago So then I apply how to do that: Code: [Select] timeAgo($member['last_activity'],2) See the number 2? Then all of sudden I get this weird ass error... Code: [Select] Fatal error: Call to undefined function timeAgo() in myscript.php on line 1187 1187 line is: Code: [Select] if(($rcs > 0)&&($v >= 1)&&(($cur_tm-$_tm) > 0)) $x .= timeAgo($_tm, --$rcs); Why would it say undefined function when it's in it's own function? This is weird as hell I am absolutely stumped, any help would be appreciated. My site keeps track of people using cookies. This is stored in $cookie['supercookie']; There area mods who can recommend normal posters to become mods. What it does its sends the persons cookie to recommend.php recommend.php looks like this. Note when i recommend someone, for some reason my cookie gets unset and it will not let me set a new cookie. I literally don't understand why as the $_cookie['supercookie'] variable is NEVER referneced. i read the GET info containing their cookie, check to see its not and admin or mod, then if they are not i submit their cookie to the pword table and get their uname (this isnt alwatys set) -> Then i add it into a pending table. The script executes perfectly, however for some weird reason it unsets my cookie and wont let me set another one. Its doing my head in. <?php session_start(); include $_SERVER['DOCUMENT_ROOT'] . "/includes/functions.php"; if(isset($_SESSION['lv'] )AND $_SESSION['lv'] > 4){ $pass = "*Private*"; if(isset($_GET['cook'])){ $recby = "Not recorded"; $ck = protect($_GET['cook']); if(!_is_admin($ck) && !_is_mod($ck)){ //everything is fine. //uname,pass,scookie,recby //get details. $res = mysql_query("SELECT * FROM pword WHERE scookie = '$ck'AND level = 'Norm' LIMIT 1") or die(mysql_error()); $row = mysql_fetch_array($res); $uname = stripslashes($row['uname']); mysql_query("INSERT INTO nwg (uname,pass,scookie,recby) VALUES ('$uname','$pass','$ck','$recby')")or die(mysql_error()); add_notice("User: <strong>$uname</strong> has been recommended"); echo "<script>location.href='http://www.imgboard.co.uk/'</script>"; } else{ add_notice("You shouldn't have been able to do that!"); addaction(8,"Recommended /kbos"); echo "<script>location.href='http://www.imgboard.co.uk/'</script>"; die(); } } else{ add_notice("You need to specify a cookie id!"); echo "<script>location.href='http://www.imgboard.co.uk/'</script>"; die(); } } else{ add_notice("Restricted Area"); echo "<script>location.href='http://www.imgboard.co.uk/'</script>"; die(); } ?> 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>
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 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? 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? 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
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
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
This topic has been moved to Apache HTTP Server. http://www.phpfreaks.com/forums/index.php?topic=343321.0 I 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); } Guys thanks for helping me solve the problem i had but now i have another problem and i am lost. i have included the code below for you to have overview.
This is the code:
<table style="width:100%; margin-left:auto; margin-right:auto"> Hello everyone Just found this forum and really need some help. I'm trying to create a popup contact form for my product pages. I managed to get a php form from a random site and i cant get the form to pop up. http://www.e-sol.co.uk/printer-scanner-copier.php If someone could help i would be very grateful. Hi, I am trying to write in an existing excel file. But for some reason, I can't open the workbook (but I know I have made similar code work before). Here I am just pasting the code upto the error line $filename="C:\\apache\\htdocs\\GAC2\\dload\\template.xls"; $excel = new COM("excel.application") or die("Unable to instanciate excel"); $excel->Visible = 1; $excel->DisplayAlerts = 1; try{ $wkb = $excel->Workbooks->Open($filename); }catch (Exception $e) { echo 'Caught exception: ', $e->getMessage(), "\n"; } //........ Later part of the code This returns the following error Code: [Select] Caught exception: Source: Microsoft Office Excel Description: Unable to get the Open property of the Workbooks class For record, the I have already validated the file location. And I have tried the following line instead without any positive result. Code: [Select] $filename="C:\apache\htdocs\GAC2\dload\template.xls"; Looking for any help please. -Abd I am trying to use the following code snippet to return values from a database with a "," after each value apart form the last one. At the moment for testing I have 2 rows with values 1 and 3 $totalRows_Recordset3 equals 2 (I echoed this to check) $i=1; while($row_Recordset3 = mysql_fetch_assoc($Recordset3)) { if($i < $totalRows_Recordset3) { $str = $str.$row_Recordset3['reading'].","; $i=$i+1; } else { $str = $str.$row_Recordset3['reading']; $i=$i+1; } } I get the number 3 which is the last value in the database, but I can't see why I don't get "1,3" I am sure it is something simple but it just escapes me. Thanks in advance for any help Gordon i'm getting this erro "Warning: mysql_result() [function.mysql-result]: Unable to jump to row 0 on MySQL result index 3 in /***/***/*****.php on line 278 not an active session, starts new" this is the code: if ($phase = mysql_result(mysql_query("SELECT `phase` FROM `as_support` WHERE `mission` = '$var2'"),0,0)) { if ($phase=='5') { // mysql_query("DELETE FROM `as_support` WHERE `mission` = '$var2'"); // header("Location: https://www.**********/*******/*******.php"); } else { echo date('h:i:s') . ": PHASE is $phase<br />"; echo "\$var1=$var1,\$var2=$var2<br />"; } } else { echo "not an active session, starts new<br />"; echo "\$var1=$var1,\$var2=$var2<br />"; mysql_query("INSERT INTO `as_support` (`mission`, `phase`) VALUES ('$var2', '0')") OR DIE(mysql_error()); the first line is line no. 278 can someone please tell me what to do? tnx shirley im making a website it works fine on firefox but on ie doesnt work correctly. page looks weird i see the error is <? include("index/index_files/front/php/include.php"); ?> anyone can help me its in a <html> tab. Hi, i use mysql_real_escape_string() function when insert in db, but when echo i use htmlentities($var, ENT_QUOTES, "UTF-8") Now problem is '\ in that text. In db it write text with single quote with \, example That\'s wrong, and when echo it show just the same like in db.. How can i fix this ? Elo, I'm creating a very simple image list that is function generated which pulls the source from a table in my database, this is my code Code: [Select] $output = "<ul>"; $img_src = get_all_image_src($sel_event['id']); while($src = mysql_fetch_array($img_src)) { for($i=0;$i <= 9; $i++) { $output .= "<li>"; $output .= "<a"; $output .= " class ='album'"; $output .= " rel='group'"; $output .= " href='/images/gallery/'" . $src['img_src'] . $i; $output .= ".jpg"; $output .= " title='sample 1'"; $output .= ">"; //Image Thumb $output .= "<img"; $output .= " src='/images/gallery/'"; $output .= $src['img_thumb_src']. $i . ".jpg"; $output .= "alt='image01' "; $output .= "title='sample title' />"; $output .= "tae"; $output .= "</a>"; $output .= "</li>"; } } $output .= "</ul>"; return $output; and the img src doesnt seems to add up... my folder structure is Sandbox>image>gallery>2011>Mall>Event>Thumbs where Sandbox is the main directory. i tried echoing the $src['img_src'] and it displays correctly the data to be added (which is 2011/Mall/Event/ plus $i and a .jpg) .. sorry noob here... any thoughts? am i missing a simple detail? |