ehpratah 48 Posting Whiz in Training

you have an error in your insert statement try removing this part '', before this '$_POST[fname]',at the beginning of your statement

ehpratah 48 Posting Whiz in Training

sorry but I don't get what does require_once("../includes/config.php");and require_once("../includes/dbconnect.php"); does. before what I learn is really basic. What is requires inside this includes?

to answer your question require_once is just the info of your database and server connection which is in your code the $conn = mysql_connect("localhost", "root", "") or die ("Could not connect to server"); and $db = mysql_select_db("Smartlocker", $conn) or die ("Could not connect to database"); part

ehpratah 48 Posting Whiz in Training

thanks @diafol guess i'll try ajax even though im not really familiar with it...not bad learning new things after all...can you give me some links that explain it cleary in the most simple way?

ehpratah 48 Posting Whiz in Training

Hi to All

Just wondering how cn i achieve something like this example

i select January for the first list menu and select 2013 for the second one now what im trying to achieve here is how to show all the data for the said month and year without submitting the form. i dont thing i can use javascript on this one...what should i use?

also you can look at this reference for better visualization

http://www.lazada.com.ph/shop-laptops/asus/?price=10000-19999&sort=popularityasc&dir=asc

thanks neil

ehpratah 48 Posting Whiz in Training

@LastMitch
yeah found it while looking for some Enlightenment on google on how to make it work..but i already forgot how i solved it LoL:D anyway happy new year guyzz!!!!

ehpratah 48 Posting Whiz in Training

@diafol thanks got it

i put it in this part of the code

 <?php
            //show records
            $query = mysql_query("SELECT * FROM  {$statement}  ORDER BY timestamp DESC LIMIT {$startpoint} ,  {$limit}");

            while ($row = mysql_fetch_assoc($query)) {
  ?>
            <div class="record round"><?php echo "<a href=index.php?id=$row[id]> $row[title]"; echo"</a>";?></div>
ehpratah 48 Posting Whiz in Training

Hi All

Just have a question

I'm having difficulties in displaying my data in Desc..cant find where i need to put the DESC in my query

this is the code

function.php

<?php
   function pagination($query, $per_page = 10,$page = 1, $url = '?'){        
        $query = "SELECT COUNT(*) as `timestamp` FROM {$query}";
        $row = mysql_fetch_array(mysql_query($query));
        $total = $row['timestamp'];
        $adjacents = "2"; 

        $page = ($page == 0 ? 1 : $page);  
        $start = ($page - 1) * $per_page;                               

        $prev = $page - 1;                          
        $next = $page + 1;
        $lastpage = ceil($total/$per_page);
        $lpm1 = $lastpage - 1;

        $pagination = "";

        if($lastpage > 1)
        {   
            $pagination .= "<ul class='pagination'>";
                    $pagination .= "<li class='details'>Page $page of $lastpage</li>";
            if ($lastpage < 7 + ($adjacents * 2))
            {   
                for ($counter = 1; $counter <= $lastpage; $counter++)
                {
                    if ($counter == $page)
                        $pagination.= "<li><a class='current'>$counter</a></li>";
                    else
                        $pagination.= "<li><a href='{$url}page=$counter'>$counter</a></li>";                    
                }
            }
            elseif($lastpage > 5 + ($adjacents * 2))
            {
                if($page < 1 + ($adjacents * 2))     
                {
                    for ($counter = 1; $counter < 4 + ($adjacents * 2); $counter++)
                    {
                        if ($counter == $page)
                            $pagination.= "<li><a class='current'>$counter</a></li>";
                        else
                            $pagination.= "<li><a href='{$url}page=$counter'>$counter</a></li>";                    
                    }
                    $pagination.= "<li class='dot'>...</li>";
                    $pagination.= "<li><a href='{$url}page=$lpm1'>$lpm1</a></li>";
                    $pagination.= "<li><a href='{$url}page=$lastpage'>$lastpage</a></li>";      
                }
                elseif($lastpage - ($adjacents * 2) > $page && $page > ($adjacents * 2))
                {
                    $pagination.= "<li><a href='{$url}page=1'>1</a></li>";
                    $pagination.= "<li><a href='{$url}page=2'>2</a></li>";
                    $pagination.= "<li class='dot'>...</li>";
                    for ($counter = $page - $adjacents; $counter <= $page + $adjacents; $counter++)
                    {
                        if ($counter == $page)
                            $pagination.= "<li><a class='current'>$counter</a></li>";
                        else
                            $pagination.= "<li><a href='{$url}page=$counter'>$counter</a></li>";                    
                    }
                    $pagination.= "<li class='dot'>..</li>";
                    $pagination.= "<li><a href='{$url}page=$lpm1'>$lpm1</a></li>";
                    $pagination.= "<li><a href='{$url}page=$lastpage'>$lastpage</a></li>"; …
ehpratah 48 Posting Whiz in Training

**@LastMitch ** still cant get it could you tell me what part of the query should i need to change?

here's the error

Can't select entries from table php_blog.
SELECT * FROM php_blog
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 '0, 15' at line 1
Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\unlimusic_v11 Oct 13 2012\secured\test.php on line 24
Pages:(1) [1]

ehpratah 48 Posting Whiz in Training

Hi guys need some extra help/eye here to point out what am i doing wrong

basically i want to display the data from mydbase.by the way the purpose of this page is for posting article anyway what im trying to do is put a Next and previous navigation bar but it seems that even in displaying the data is not working any dea how to do it?

here's the complete code with the necessary changes (original code by himerus)

<?php
$server = "localhost";
$user = "root";
$pass = "";
$databasename = "mydatabase";
$db = mysql_connect($server, $user, $pass);
    mysql_select_db($databasename,$db);

        $sql = "SELECT * FROM php_blog ";
        $query = mysql_query($sql,$db);
        $total_results = mysql_num_rows($query);
        $limit = "15"; //limit of archived results per page.
        $total_pages = ceil($total_results / $limit); //total number of pages
if (empty($page))
    {
        $page = "1"; //default page if none is selected
    }
$offset = ($page - 1) * $limit; //starting number for displaying results out of DB

    $query = "SELECT * FROM php_blog ORDER BY timestamp DESC LIMIT 3 $offset, $limit";
    $result = mysql_query($query);
//This is the start of the normal results...

    while ($row = mysql_fetch_array($result))
        {

    $date = date("l F d Y", $row['timestamp']);

    $title = stripslashes($row['title']);
    $author = stripslashes($row['author']);
    $cat = stripslashes($row['category']);
    $intro = stripslashes($row['intro']);
        }
        mysql_close();


// This is the Previous/Next Navigation
echo "<font face=Verdana size=1>";
echo "Pages:($total_pages)&nbsp;&nbsp;"; // total pages
if ($page != 1)
{
echo "<a href=$PHP_SELF?page=1><< First</a>&nbsp;&nbsp;&nbsp;"; // First Page Link
$prevpage = $page - 1;
echo "&nbsp;<a href=$PHP_SELF?page=$prevpage><<</a>&nbsp;"; // Previous Page Link
}
        if …
ehpratah 48 Posting Whiz in Training

hi nevermind my first post i think this is what your looking for

<?php



$contact_name = $_POST['contact_name'];
$contact_email = $_POST['contact_email'];
$contact_text = $_POST['contact_text'];



if (!empty($contact_name) && !empty ($contact_email) && !empty ($contact_text))
    {
echo "ok";
} else{
echo "All fields are required.";
}

?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">

Name:<br><input type="text" name="contact_name"><br><br>
Email adress:<br><input type="text" name="contact_email"><br><br>
Message:<br>
<textarea name="contact_text" rows="6" cols="30"></textarea><br><br>
<input type="submit" value="send">
</form>
ehpratah 48 Posting Whiz in Training

hi you can also look at this code that i came up using your code with slight modification on it

<?php
if(isset($_POST['submit']))
{

$contact_name = $_POST['contact_name'];
$contact_email = $_POST['contact_email'];
$contact_text = $_POST['contact_text'];

if (!empty($contact_name) && !empty ($contact_email) && !empty ($contact_text)){
echo ("OK.");

} else{
echo "All fields are required.";

}

}

?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
Name:<br><input type="text" name="contact_name"><br><br>
Email adress:<br><input type="text" name="contact_email"><br><br>
Message:<br>
<textarea name="contact_text" rows="6" cols="30"></textarea><br><br>
<input type="submit" value="Send">
</form>

not been tested if it really work but you can always find it out:D

ehpratah 48 Posting Whiz in Training

hey i think this part of the code is wrong

<form action="index.php" method="post">

you must replace it with

<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">

ehpratah 48 Posting Whiz in Training

Got it..some of the hosting site generate their own code on how to connect to the server now i know..:)

ehpratah 48 Posting Whiz in Training

Hi need some assistance here im having an error connecting my database to the server online,the thing is it is working fine in localhost but when i uploaded it just wont work.. i already change the necessary string to match the server configuration online

from config.php this is in the localhost

<?php
    define('DB_HOST', 'localhost');
    define('DB_USER', 'root');
    define('DB_PASSWORD', '');
    define('DB_DATABASE', 'subscribe');
?>

to config.php thisis on the server

<?php
    define('DB_HOST', 'localhost');
    define('DB_USER', 'xxxx');
    define('DB_PASSWORD', 'xxx');
    define('DB_DATABASE', 'xxxx');
?>

but still having this error

Failed to connect to server: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

all suggestion are welcome thanks and if you want the complete code i can post it

ehpratah 48 Posting Whiz in Training

hi fellas out thiere im having a headache right now in sending email with attachment..im using ftp in storing the file in my dirctory and sending it to my email...i can upload the file and send it but the prolem is when i try to dowload the file from the email it has no data as in "0 bytes"..any suggestion or insight please thanks..i just modify this code for my needs...

here is the sendmail.php

<?php

   $ftp_server='www.mysite.com';//serverip
   $conn_id = ftp_connect($ftp_server); 


   // login with username and password
   $user="myusername";
   $passwd="mypassword";
   $login_result = ftp_login($conn_id, $user, $passwd); 

// check connection
   if ((!$conn_id) || (!$login_result)) { 
       echo "FTP connection has failed!";
       echo "Attempted to connect to $ftp_server for user $ftp_user_name"; 
       die; 
   } else {
       echo "<br>Connected to $ftp_server, for user $user<br>";
   }
//directorylike /www.mydomain.com/upload/upload
  ftp_chdir($conn_id, "public_html/mail/upload");

//here we create the unique name for the uploaded file so that it wont overwrite an existing file
$uniqueID = uniqid("");
$destination_file= $uniqueID.".doc";

echo ("<br>");
print $destination_file;
echo ("<br>");

// upload the file
$upload = ftp_put($conn_id, $destination_file, $source_file, FTP_BINARY); 

// check upload status
if (!$upload) { 
       echo "FTP upload has failed!";
   } else {
       echo "Uploaded $source_file to $ftp_server as $destination_file";
   }

// close the FTP stream 
ftp_close($conn_id); 
?>
<html>
<head>
<title></title>
</head>
<Body>
<form name="form1" method="post" action="mail.php">
  <p>
    <input name="id" type="text" id="id" value="<?php echo $destination_file; ?>">
</p>
  <table width="75%"  border="1">
    <tr>
      <td><div align="right">Name:</div></td>
      <td><input name="nume" type="text" id="nume"></td>
    </tr>
    <tr>
      <td><div align="right">Surnume:</div></td>
      <td><input name="prenume" type="text" id="prenume"></td>
    </tr>
    <tr>
      <td><div align="right">E- mail: </div></td>
      <td><input name="email" type="text" id="email"></td>
    </tr>
    <tr>
      <td><div …
ehpratah 48 Posting Whiz in Training

hi thanks for the reply even though its not really what im looking for i appriciate your effort..thanks dude

ehpratah 48 Posting Whiz in Training

Hi im having a nerve wrecking problem with my script, i'm trying to make a form validation that when a field is empty it will prompt a message that needs fo fill up the missing fields..and i made it already the problem is when i put a separate script for selectbox that dynamically change when the user try to select a category the validation code stop working..and i've already try everything that i can think of to solve it and with no avail..heres the code..

     <!DOCTYPE html>
    <html>
    <head>
      <meta http-equiv="content-type" content="text/html; charset=UTF-8">


      <script type='text/javascript' src='jscript/jquery.min.js'></script>



      <style type='text/css'>

      </style>

<!------------------------SCRIPT FOR THE DYNAMICALLY CHANGE SELECTBOX--------------------------------------> 

    <script type='text/javascript'>//<![CDATA[ 
    $(window).load(function(){
    $(document).ready(function() {
            $('#txtarea').change(function() {
            $("#txtorigin").empty();
            $("#txtdestination").empty();
            $("#txtvehicle").empty();
            $("<option value='0'>Select</option>").appendTo("#txtorigin");
            $("<option value='0'>Select</option>").appendTo("#txtdestination");
            $("<option value='0'>Select</option>").appendTo("#txtvehicle");
            if ($(this).val() == "1") { 
                $("<option value='1'>NAIA 1</option>").appendTo("#txtorigin");
                $("<option value='2'>NAIA 2</option>").appendTo("#txtorigin");
                $("<option value='3'>NAIA 3</option>").appendTo("#txtorigin");
                $("<option value='4'>Hotel Intercontinental Manila</option>").appendTo("#txtorigin");
                $("<option value='5'>New World Hotel</option>").appendTo("#txtorigin");
                $("<option value='6'>Best Western F1 Hotel</option>").appendTo("#txtorigin");
                $("<option value='7'>Go Hotels Mandaluyong</option>").appendTo("#txtorigin");
                $("<option value='8'>Tune Hotel-Malate</option>").appendTo("#txtorigin");

                $("<option value='9'>Toyota VIOS 1.3 MT</option>").appendTo("#txtvehicle");
                $("<option value='10'>Toyota VIOS 1300 E AT</option>").appendTo("#txtvehicle");
                $("<option value='11'>Toyota VIOS 1500 G AT</option>").appendTo("#txtvehicle");
                $("<option value='12'>Toyota ALTIS 1600 E MT</option>").appendTo("#txtvehicle");
                $("<option value='13'>Toyota INNOVA 2.0 J GAS MT</option>").appendTo("#txtvehicle");
                $("<option value='14'>Toyota INNOVA J Dsl MT</option>").appendTo("#txtvehicle");

                 $("<option value='15'>NAIA 1</option>").appendTo("#txtdestination");
                $("<option value='16'>NAIA 2</option>").appendTo("#txtdestination");
                $("<option value='17'>NAIA 3</option>").appendTo("#txtdestination");
                $("<option value='18'>Hotel Intercontinental Manila</option>").appendTo("#txtdestination");
                $("<option value='19'>New World Hotel</option>").appendTo("#txtdestination");
                $("<option value='20'>Best Western F1 Hotel</option>").appendTo("#txtdestination");
                $("<option value='21'>Go Hotels Mandaluyong</option>").appendTo("#txtdestination");
                $("<option value='22'>Tune Hotel-Malate</option>").appendTo("#txtdestination");

            }
            else if ($(this).val() == "2") {
                $("<option value='1'>Holiday Inn Clark Pampanga</option>").appendTo("#txtorigin");
                $("<option value='2'>Tune Hotel - Clark</option>").appendTo("#txtorigin");

                $("<option value='3'>Toyota VIOS 1.3 MT</option>").appendTo("#txtvehicle");
                $("<option value='4'>Toyota INNOVA 2.0 J GAS MT</option>").appendTo("#txtvehicle"); …
ehpratah 48 Posting Whiz in Training

well by looking at your code i can say that you make a big mess out their try looking at your first post and you can see were you made the mistake and try to rereading your own post,it will help you back in the track..let em give some hint

your missing this part

    $host = "localhost"; 
    $user = "root";
    $pass = "";   
    $database_name = "phl"; //database name

and also change this

 $sql = "INSERT INTO products (PU_NUMBER, PU_DESC, UNIT_ASS) 
                values($_POST['pu_number'], $_POST['PU_DESC'],$POST['UNIT_ASS'])";

with this

$sql = "INSERT INTO products (PU_NUMBER, PU_DESC, UNIT_ASS)  VALUES('".$_POST[pu_number]."', '".$_POST[PU_DESC]."', '".$_POST[UNIT_ASS]."')";
ehpratah 48 Posting Whiz in Training

you can also use UNION but as broj1 said without knowing the structure of your table its hard to tell..geez i just repeat what broj1 said..anyway you can use either of this..

ehpratah 48 Posting Whiz in Training

you should declare first your data to be save in a variable on the top of your code like for pu_number_products you can put a variable name like

    <?php

    $pu_number_products=$_POST['pu_number_products'];


    and so on.......
ehpratah 48 Posting Whiz in Training

try changing this

 $sql = "insert into products (PU_NUMBER, PU_DESC, UNIT_ASS) VALUES('$_POST[pu_number_products]', '$_POST[pu_description_products]', '$_POST[unit_ass_products]')";

with this

$sql = "INSERT INTO products (PU_NUMBER, PU_DESC, UNIT_ASS)  VALUES('".$_POST[pu_number_products]."', '".$_POST[pu_description_products]."', '".$_POST[unit_ass_products]."')";
ehpratah 48 Posting Whiz in Training

try something like this..

echo "<td><a href=delete.php?user_id=$row[user_id] onclick=return confirm('Do you want to delete?')> DELETE</a></td>";

not hundred percent sure..i just get it on top of my head..nothing wrong with trying:D

ehpratah 48 Posting Whiz in Training

CooOl...hey blocblue great work..yeah it is working great now..thanks alot man...im so in debt with you man your the best,great coding..hope i can be good as so when it came to this kind of stuff..thank you:)

ehpratah 48 Posting Whiz in Training

@blocblue:yeah the grace period is always 5hrs from the pick up date

ex
startdate:2012-06-01
pick up hour:09:00:00
startdate:2012-06-02
return hour:17:00:00

rate:5000

but if
startdate:2012-06-01
pick up hour:09:00:00
startdate:2012-06-02
return hour:09:00:00

rate:2500

aside from that its already working fine thanks to you..

@diafol: yeah i agree with you i can say that blocbro have things for number..and sad to say i dont have that thing and i will never have that..

ehpratah 48 Posting Whiz in Training

yah it already solve my current problem..but then im still seeing some small flaws you see when i try to put 2012-06-01 and 2012-06-01 im getting 0 for rate..i am just thinking if it is when 2012-06-01 and 2012-06-01 it will have a default rate as 2500..but the other from 2012-06-01 to 2012-06-02 up i have no problem anymore

ehpratah 48 Posting Whiz in Training

again thank you so much blocblue for the great help..still cant say that my problem is over yet..but then again thanks bro your the man..

ehpratah 48 Posting Whiz in Training

hi blocblue its you again.. thank you for the quick reply and sorry if im bothering you again..

im still having a wrong output when i put

startdate=2012-06-01
pickup hour=06:00

enddate=2012-06-02
return hour=06:00

im getting rate:5000 which is wrong it should be rate:2500 because it is just equivalent to 24hrs

it will only change to rate:5000 when the return hour=11:00 or higher..

ehpratah 48 Posting Whiz in Training

typo error in my statement

what i mean is

the issue is when i compute for a car rate..it will depend on the date of rental and the return date,which is already coverd the problem is it will not really just depend on the date but also in time of return

e.g
format(yyyy-mm-d)
startdate=2012-06-01
pickup hour=06:00

enddate=2012-06-02
return hour=06:00

rate:2500

but if the return hour is already 5hour past than the pickup hour then rate=5000

e.g
startdate=2012-06-01
pickup hour=06:00

enddate=2012-06-02
return hour=11:00

rate:5000

any suggestion or samples..

ehpratah 48 Posting Whiz in Training

hi i have a little bit of issue just thingking if somebody can give me a hand out here..

the issue is when i compute for a car rate..it will depend on the date of rental and the return date,which is already coverd the problem is it will not really just depend on the date but also in time of return

e.g
format(yyyy-mm-d)
startdate=2012-06-01
pickup hour=06:00

enddate=2012-06-02
return hour=06:00

rate:2500

but if the return date is already 5hour past than the pickup hour then rate=5000

e.g
startdate=2012-06-01
pickup hour=06:00

enddate=2012-06-02
return hour=11:00

rate:5000

here is the code in computing for the rate by day,week and month..but no idea how to compute the excess hour..

<?php  
  $vehicle;
  date_default_timezone_set('Europe/London');

  function rate($start_date, $end_date)
{
    $interval = calculate_interval($start_date, $end_date);
    // Total months
    $months = floor($interval / DAYS_IN_MONTH);
    $interval = $interval % DAYS_IN_MONTH;
    // Total weeks
    $weeks = floor($interval / DAYS_IN_WEEK);
    $interval = $interval % DAYS_IN_WEEK;
    // Total days
    $days = $interval;
    // Calculate total cost
    return ($months * COST_PER_MONTH) + ($weeks * COST_PER_WEEK) + ($days * COST_PER_DAY);
}
/**
 * Find total number of days passed between start and end dates inclusive.
 *
 * @param string $start_date
 * @param string $end_date
 * @return integer
 */
function calculate_interval($start_date, $end_date)
{
    return floor((strtotime($end_date) - strtotime($start_date) + SECONDS_IN_DAY) / SECONDS_IN_DAY);
}
$start_date = '2012-06-01';
$pickuphour='06:00';
$end_date = '2012-06-02';
$returnhour='11:00';

if($vehicle=="Toyota VIOS 1.3 MT")
{

define('SECONDS_IN_DAY', 86400);
define('DAYS_IN_MONTH', 30);
define('DAYS_IN_WEEK', 7);
define('COST_PER_MONTH', 52500);
define('COST_PER_WEEK', 15000);
define('COST_PER_DAY', 2500);

}

if($vehicle=="Toyota VIOS 1300 …
ehpratah 48 Posting Whiz in Training

ok got it...i just need to incorporate it with the proj..again thanks alot!

ehpratah 48 Posting Whiz in Training

blocblue!!!thank you so much!!!!its perfect!your the best man..you save my ass out here..i'm in debt with you gain thank you so much....

ehpratah 48 Posting Whiz in Training

im still not getting it the right output

here is the thing

if i put in date1 2012-06-01 and on date2=2012-06-01 it needed to have a default total and that total must be 2500..but if i change date2 to 2012-06-02 thats the time that it will need to add another 2500 to get the total of 5000

e.g

date1=2012-06-01
date2=2012-06-01

total=2500

e.g
date1=2012-06-01
date1=2012-06-02

total=5000

and so on until it get to

date1=2012-06-01
date1=2012-06-07

total=15000

again sorry if im pulling you to my problem..but help is really needed out here..thanks

ehpratah 48 Posting Whiz in Training

hi i got it already but the problem is im getting wrong output

here's the code

    <?php

    $timezone = "Asia/Shanghai";
    if(function_exists('date_default_timezone_set')) date_default_timezone_set($timezone);
    echo date('d-m-Y H:i');

    /*These look like they are sent via form submit to this program*/
    $date1 = '2012-06-01'; // pick up date
    $date2 = '2012-06-01'; // return date

    $perday=2500;
    $permonth=52500;
    $perweek=15000;


    $datetime1 = new DateTime($date1);
    $datetime2 = new DateTime($date2);
    $interval = $datetime1->diff($datetime2); // the math for the difference
    $rest =  $interval->format('%d days');  // this may contain weeks
    $week = intval($rest / 7);              // weeks extracted from the above var.                
    $mon = $interval->format('%m');  // The mon from formatting
    $day = intval($rest % 7);      // This line MUST STAY to figure number of days

    echo 'week '.$week . '<br />';  // The echos are for your benifit and should be commented out or erased
    echo 'day '.$day . '<br />';
    echo ' months '.$mon .'<br />';


    $total = $mon * $permonth + $week * $perweek + $day * $perday;
    echo $total . '<br />';
    ?> 

in the date part of this code i try to put the pick up date to 2012-06-01 the same with the return date..but im having a wrong output

it must be " 2500 "

but instead im getting this 0 for the total

22-06-2012 20:21
week 0
day 0
months 0
0

and also when i change the pick up date to 2012-06-01 and the return date to 2012-06-02

instead of getting "5000"

im getting

22-06-2012 20:28

week 0

ehpratah 48 Posting Whiz in Training

ok but when i put new DateTime(); im having this error

Fatal error: Uncaught exception 'Exception' with message 'DateTime::__construct() [<a href='datetime.--construct'>datetime.--construct</a>]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'UTC' for '8.0/no DST' instead' in C:\xampp\htdocs\msicfinal\samp.php:10 Stack trace: #0 C:\xampp\htdocs\msicfinal\samp.php(10): DateTime->__construct('2012-04-01') #1 {main} thrown in C:\xampp\htdocs\msicfinal\samp.php on line 10

any idea?

ehpratah 48 Posting Whiz in Training

hi im having an error with my code can anyone help me try to fix my problem

the error is

Fatal error: Call to a member function diff() on a non-object in C:\xampp\htdocs\msicfinal\samp.php on line 12

and my code is

<?php
/*These look like they are sent via form submit to this program*/
$date1 = '2012-04-01'; // pick up date
$date2 = '2012-05-27'; // return date

$perday=2500;
$permonth=52500;
$perweek=15000;

$datetime1 = ($date1);
$datetime2 = ($date2);
$interval = $datetime1->diff($datetime2); // the math for the difference
$rest =  $interval->format('%d days');  // this may contain weeks
$week = intval($rest / 7);              // weeks extracted from the above var.                
$mon = $interval->format('%m');  // The mon from formatting
$day = intval($rest % 7);      // This line MUST STAY to figure number of days



$total = $mon * $permonth + $week * $perweek + $day * $perday;
echo $total . '<br />';
?> 

the purpose of this code is to compute the rate depending on the date

ehpratah 48 Posting Whiz in Training

and if you need to see the actual web here is the link http://europcar1.com.ph/selfdrive.php

just choose NO in the part that will ask you if you have a corporate accnt..thanks

ehpratah 48 Posting Whiz in Training

228

This post has no text-based content.
ehpratah 48 Posting Whiz in Training

this are the screenshot output

146

ehpratah 48 Posting Whiz in Training

hi need a hand here..

im having trouble in making my code work(well actually im not getting it)what i need to do is to compute the rate of vehicle that is rented..the only thing that i came up is with the perday rate and the other 2 i cant find a way(i really sucks with formula )here is the thing..

SELF - DRIVE RATES

  1. Minimum rental periods :
    Daily - 24 hours
    Weekly - 7 days
    Monthly - 30 days

CAR
Toyota VIOS 1.3 MT
DAILY
2,500

WEEKLY
15,000

MONTHLY
52,500

and this is the code that i can came up

<?php
$rday=$_POST['txtrday'];
$pday=$_POST['txtpday'];
  $vehicle;

    $phr;
    $total;
    $totalhr;
    $pday;
    $totald;
    $totalday;
    $rmonth;
    $pmonth;
    $totalm;
    $totalmonth;

if($vehicle=="Toyota VIOS 1.3 MT")
{
    $perday=2500;
    $permonth=52500;
    $perweek=15000;

    if($rday>$pday)
        {
        $totald=($rday)-($pday);

        }
    else if($rday==$pday)
        {
        $totalday=$perday;
        }


    if($rmonth>$pmonth)
        {
        $totalm=$rmonth-$pmonth;


        }
    else if($rmonth==$pmonth)
        {
        $totalmonth;
        }

        $totalday=$perday * $totald+2500;
        $totalmonth=$totalm * $permonth;
        $rate=$totalday + $totalmonth;     
}
?>

this will be the weekly rate output

e.g
form1
vehicle=Toyota VIOS 1.3 MT
pday=3
rday=10
when click submit it will be directed in

form2

rate=15000

because it is already equivalent to 7 days

in need of lot of help right now ..this will be the last part of my project so please

ehpratah 48 Posting Whiz in Training

embarrassing..it took me 1 whole day to figure out whats the problem with the code and with no avail in finding any..just a moment ago i figured out that i put the same price in twice..thats explain why im getting wrong output..:(

ehpratah 48 Posting Whiz in Training

yeah i miss that one..gonna check if its work...as for the $zone yeah it is base on the input of the user. well basically the user will choose from a dropdown menu to get the zone..

ehpratah 48 Posting Whiz in Training

but when it comes to Paranaque 1 its not working properly.. i already try to scan and find a bug in my code but i cant find any..

ehpratah 48 Posting Whiz in Training

@ cerial: well in the lower or upper case issue its not really a problem because i use jquery to make all the input text all uppercase..the weard thing is the other condtion is working fine..

here is an example code that show the correct rate

if(($origin=="NAIA 1" && $vehicle=="Vios" && $zone=="Quezon 7") && ($destination=="REGALADO HIWAY" || $destination=="PASONG PUTTING" || $destination=="KALIGAYAHAN" || $destination=="COMMONWEALTH"))
{
$rate=2200;
}   
if(($origin=="NAIA 1" && $vehicle=="Innova" && $zone=="Quezon 7") && ($destination=="REGALADO HIWAY" || $destination=="PASONG PUTTING" || $destination=="KALIGAYAHAN" || $destination=="COMMONWEALTH"))
{
$rate=3280;
}
if(($origin=="NAIA 1" && $vehicle=="Van" && $zone=="Quezon 7") && ($destination=="REGALADO HIWAY" || $destination=="PASONG PUTTING" || $destination=="KALIGAYAHAN" || $destination=="COMMONWEALTH"))
{
$rate=4900;
}
ehpratah 48 Posting Whiz in Training

here is the complete code but it is really a mess so please bare with me

<?php  
// NAIA TRANSFER-------------------------------------------------------
if($origin=="NAIA 1" && $vehicle=="Vios" && $zone=="Inter NAIA" && $destination=="NAIA 2")
{
$rate=300;
}   
 if($origin=="NAIA 1" && $vehicle=="Innova" && $zone=="Inter NAIA" && $destination=="NAIA 2")
{
$rate=590;
}
if($origin=="NAIA 1" && $vehicle=="Van"  && $zone=="Inter NAIA" && $destination=="NAIA 2")
{
$rate=880;
}   
if($origin=="NAIA 1" && $vehicle=="Vios" && $zone=="Inter NAIA"  && $destination=="NAIA 3")
{
$rate=450;
}       
if($origin=="NAIA 1" && $vehicle=="Innova" && $zone=="Inter NAIA" && $destination=="NAIA 3")
{
$rate=775;
}   
if($origin=="NAIA 1" && $vehicle=="Van" && $zone=="Inter NAIA" && $destination=="NAIA 3")
{
$rate=1100;
}   
if($origin=="NAIA 1" && $vehicle=="Vios" && $zone=="Inter NAIA" && $destination=="OLD DOMESTIC")
{
$rate=380;
}   
if($origin=="NAIA 1" && $vehicle=="Innova" && $zone=="Inter NAIA" && $destination=="OLD DOMESTIC")
{
$rate=630;
}   
if($origin=="NAIA 1" && $vehicle=="Van" && $zone=="Inter NAIA" && $destination=="OLD DOMESTIC")
{
$rate=880;
}
//--------------------------PASAY 1-------------------- 
if(($origin=="NAIA 1" && $vehicle=="Vios" && $zone=="Pasay 1") && ($destination=="VILLAMOR AIRBASE" || $destination=="RIVERA" || $destination=="AIRMEN'S VILLAGE" || $destination=="PILDERA 1" || $destination=="PILDERA 2"))
{
$rate=500;
}
if(($origin=="NAIA 1" && $vehicle=="Innova" && $zone=="Pasay 1") && ($destination=="VILLAMOR AIRBASE" || $destination=="RIVERA" || $destination=="AIRMEN'S VILLAGE" || $destination=="PILDERA 1" || $destination=="PILDERA 2"))
{
$rate=750;
}
if(($origin=="NAIA 1" && $vehicle=="Van" && $zone=="Pasay 1") && ($destination=="VILLAMOR AIRBASE" || $destination=="RIVERA" || $destination=="AIRMEN'S VILLAGE" || $destination=="PILDERA 1" || $destination=="PILDERA 2"))
{
$rate=1125;
}
//--------------------------PASAY 2---------------------
if(($origin=="NAIA 1" && $vehicle=="Vios" && $zone=="Pasay 2") && ($destination=="GSIS" || $destination=="SENATE" || $destination=="WTC" || $destination=="FB HARRISON" || $destination=="BSP" || $destination=="CENTURY PARK" || $destination=="RUSSIAN EMBASSY" || $destination=="VIETNAM EMBASSY" || $destination=="RIZAL MEMORIAL"))
{
$rate=550;
}   
if(($origin=="NAIA 1" && $vehicle=="Innova" …
ehpratah 48 Posting Whiz in Training

well basically the user will fill up a form. in that form theire is a texbox such as txtzone,txtvehicle,txtorigin and txtdestination..when submitted it must show the rate of the vehicle

e.g
if origin is equal to "NAIA 1" AND zone is equal to "Paranaque 1" AND vehicle is equal to "VIOS "AND destination is equal to "UNIWIDE" OR "COSTAL MALL" OR "DFP " THEN rate is 550

OUTPUT

zone= Paranaque 1
vehicle=VIOS
origin=NAIA 1
destination=DFP

RATE : PHP 550.00

but im having an error it display a wrong rate..

ehpratah 48 Posting Whiz in Training

hi anybody can help me analyze this code..im not getting the correct output..

if(($origin=="NAIA 1" && $vehicle=="Small Car" && $zone=="Paranaque 2") && ($destination=="BACLARAN" || $destination=="SAN DIONISIO" || $destination=="BICUTAN INTERCHANGE" || $destination=="MULTINATIONAL VILLAGE" || $destination=="MOONWALK" || $destination=="SM SUCAT" || $destination=="DON BOSCO" || $destination=="SUN VALLEY" || $destination=="BETTER LIVING" || $destination=="MERVILLE" || $destination=="MARCELO GREEN" || $destination=="KALAYAAN" || $destination=="UNITED PARANAQUE"))
{
$rate=550;
}
if(($origin=="NAIA 1" && $vehicle=="Innova" &&  $zone=="Paranaque 2") && ($destination=="BACLARAN" || $destination=="SAN DIONISIO" || $destination=="BICUTAN INTERCHANGE" || $destination=="MULTINATIONAL VILLAGE" || $destination=="MOONWALK" || $destination=="SM SUCAT" || $destination=="DON BOSCO" || $destination=="SUN VALLEY" || $destination=="BETTER LIVING" || $destination=="MERVILLE" || $destination=="MARCELO GREEN" || $destination=="KALAYAAN" || $destination=="UNITED PARANAQUE"))

{
$rate=865;
}
if(($origin=="NAIA 1") && ($vehicle=="Van") && ($zone=="Paranaque 2") && ($destination=="BACLARAN" || $destination=="SAN DIONISIO" || $destination=="BICUTAN INTERCHANGE" || $destination=="MULTINATIONAL VILLAGE" || $destination=="MOONWALK" || $destination=="SM SUCAT" || $destination=="DON BOSCO" || $destination=="SUN VALLEY" || $destination=="BETTER LIVING" || $destination=="MERVILLE" || $destination=="MARCELO GREEN" || $destination=="KALAYAAN" || $destination=="UNITED PARANAQUE"))

{
$rate=1300;
}   
ehpratah 48 Posting Whiz in Training

ok i got it
instead of this
if($origin=="NAIA 1" && $vehicle=="Vans" && $destination=="Manila" || $destination=="Cam Sur" || $destination=="Boracay" )

i put
if(($origin=="NAIA 1" && $vehicle=="Van") &&( $destination=="Manila" || $destination=="Cam Sur" || $destination=="Boracay" ))

and its working now..

pritaeas commented: Thanks for sharing +13
ehpratah 48 Posting Whiz in Training

guys i'm having a really big problem right now..im trying to make a conditional statement using php but im having an logical error or syntax error..im trying to compute for the car rate but im not getting a correct output

e.g

i have a list of car which are "Small Car" "Innova" "Van" and there prices will depend on the location if the location is let say "Manila" or "Cam Sur" or "Boracay" then
Small Car price is 550.00
Innova price is 700.00
Van price is 1000.00

here is the code

<?php
 $vehicle;
      $rhr;
    $phr;
    $total;
    $totalhr;
    $rday;
    $pday;
    $totald;
    $totalday;
    $rmonth;
    $pmonth;
    $totalm;
    $totalmonth;


if($origin=="NAIA 1" && $vehicle=="Small Car" && $destination=="Manila" || $destination=="Cam Sur" || $destination=="Boracay" )
{
    $perday=3000;
    $permonth=9000;
    $perhour=125;
    $car=1740;

if($rhr>$phr)
        {
        $total=($rhr)- ($phr);
        $totalhr=$perhour * $total;

        }
    else if($rhr==$phr)
        {    
        $totalhr;
        }
    if($rday>$pday)
        {
        $totald=($rday)-($pday);
        $totalday=$perday * $totald;
        }
    else if($rday==$pday)
        {
        $totalday;
        }

    if($rmonth>$pmonth)
        {
        $totalm=$rmonth-$pmonth;
        $totalmonth=$totalm * $permonth;

        }
    else if($rmonth==$pmonth)
        {
        $totalmonth;
        }
        $rate=$car+$totalhr+$totalday;     
}
if($origin=="NAIA 1" && $vehicle=="Innova" && $destination=="Manila" || $destination=="Cam Sur" || $destination=="Boracay" )
{
    $perday=3000;
    $permonth=9000;
    $perhour=125;
    $car=1740;

if($rhr>$phr)
        {
        $total=($rhr)- ($phr);
        $totalhr=$perhour * $total;

        }
    else if($rhr==$phr)
        {    
        $totalhr;
        }
    if($rday>$pday)
        {
        $totald=($rday)-($pday);
        $totalday=$perday * $totald;
        }
    else if($rday==$pday)
        {
        $totalday;
        }

    if($rmonth>$pmonth)
        {
        $totalm=$rmonth-$pmonth;
        $totalmonth=$totalm * $permonth;

        }
    else if($rmonth==$pmonth)
        {
        $totalmonth;
        }
        $rate=$car+$totalhr+$totalday;     
}
if($origin=="NAIA 1" && $vehicle=="Vans" && $destination=="Manila" || $destination=="Cam Sur" || $destination=="Boracay" )
{
    $perday=3000;
    $permonth=9000;
    $perhour=125;
    $car=1740;

if($rhr>$phr)
        {
        $total=($rhr)- ($phr);
        $totalhr=$perhour * $total;

        }
    else if($rhr==$phr)
        {    
        $totalhr; …
ehpratah 48 Posting Whiz in Training

Guys Thanks a lot for the help its now working already..again thanks everyone:)

ehpratah 48 Posting Whiz in Training

ok thanks a lot for the advice i'll try it..hope i can make something out of it..