×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

A query in PHP results other ting the im MySQL

A query in PHP results other ting the im MySQL

A query in PHP results other ting the im MySQL

(OP)
Hi everyone,
This is my sql query:

CODE

SELECT HOUR(TIMEDIFF('16:55','16:45')) + MINUTE(TIMEDIFF('16:55','16:45'))/60; 
When I run it on my MySQL display this is what I get:

I'd like that query to be operated usin PHP code. This is my code:

CODE

<?php //MyINITIAL.PHP
$MyHOST = 'localhost';
$MyUSER = 'yossi';
$MyPASS = 'yoss4qpines';
$MyDB = 'test';
?> 

CODE

<?php //MyLOGIN.PHP
$MyCONNECTION = NEW MYSQLI($MyHOST,$MyUSER,$MyPASS,$MyDB);
IF(!$MyCONNECTION)
DIE('Gevald' .MYSQLI_CONNECT_ERROR());
MYSQLI_SET_CHARSET($MyCONNECTION,'UTF8');
?> 

CODE

<?php // to_forum.php
REQUIRE_ONCE 'MyINITIAL.php';
REQUIRE_ONCE 'MyLOGIN.php';

$MyCONNECTION = NEW MYSQLI($MyHOST,$MyUSER,$MyPASS,$MyDB);
IF(!$MyCONNECTION)
DIE(MYSQLI_CONNECT_ERROR());
MYSQLI_SET_CHARSET($MyCONNECTION,'UTF8');

$aaa=time('16:50');
$bbb=time('16:55');
$ccc="select hour(timediff('$bbb','$aaa')) + MINUTE(TIMEDIFF('$bbb','$aaa'))/60;";
$result = $MyCONNECTION->query($ccc);
if(!$result) echo $MyCONNECTION->error;
else
$res = $result->fetch_array(MYSQLI_NUM);
print_r($res);
?> 
When I run my php code this is what I get:

Why do I not get the desired result from my PHP as in my MySQL display?
Thanks

RE: A query in PHP results other ting the im MySQL

The time() function in PHP does not take any parameters. It merely returns the current time in seconds.

Passing a string to it will return the same value for both times: The current time.

Getting the difference between that, will return 0 which translates to nothing in your results..

You can simply pass the time stings as they are, and it should work.







----------------------------------
Phil AKA Vacunita
----------------------------------
OS-ception: Running Linux on a Virtual Machine in Windows which itself is running in a Virtual Machine on Mac OSx.

Web & Tech

RE: A query in PHP results other ting the im MySQL

(OP)
Thank you so much !

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close