Jump to content
×
×
  • Create New...
  • 0

PHP - Problem with select time from DB


ReFresh

Question

Hi guys,

 

I need to select time from this column.

 

 

I tried to do it with this code but I'm wasn't successful:

 

 

I got this error:

 

 

And I need to get the time with this variable:

 

 

If someone can help me I will be glad :)

 

Thanks for answers!

 

Regards,

 

ReFresh

Link to comment

10 answers to this question

Recommended Posts

  • 0

mysql too old

 

$conex = new mysqli(IP, USER, PWD);

$time = mysqli_fetch_array(mysqli_query($conex, "select create_time from account.account where id =whatever limit 1;"))["create_time"];

echo $time;

Search in google its the fastest way to get whatever you need, dont ask for help, try to do yourself or search the information.

Link to comment
  • 0
17 minutes ago, ѕeмa™ said:

mysql too old

 

$conex = new mysqli(IP, USER, PWD);

$time = mysqli_fetch_array(mysqli_query($conex, "select create_time from account.account where id =whatever limit 1;"))["create_time"];

echo $time;

Still I can't get result from DB.

PS: I'm using old CMS web 1.3 with old mysql.

Link to comment
  • 0
2 hours ago, ReFresh said:

I need to use old mysql parameters because my web is written in old mysql version.

Where I said that you need new parametres!? I saidonly select all columns and print to see if work

spacer.png

Link to comment
  • 0
On 14. 1. 2017 at 11:58 PM, Optimus said:

Where I said that you need new parametres!? I saidonly select all columns and print to see if work

I have this now and it's work but not as I want:

$qcreatetime = mysql_query("SELECT create_time FROM ".SQL_HP_DB.".account WHERE id='".$_SESSION['user_id']."'");

while ($rowcreatetime = mysql_fetch_array($qcreatetime))

{$createtime = $rowcreatetime["create_time"];

echo $createtime;}

I'm still getting this error:

Link to comment
  • 0
On 16.1.2017 at 8:14 PM, ReFresh said:

I have this now and it's work but not as I want:

$qcreatetime = mysql_query("SELECT create_time FROM ".SQL_HP_DB.".account WHERE id='".$_SESSION['user_id']."'");

while ($rowcreatetime = mysql_fetch_array($qcreatetime))

{$createtime = $rowcreatetime["create_time"];

echo $createtime;}

I'm still getting this error:IMG_20170116_201330_811.JPG

You dont need while if you want to get only one record.

I dont understand your "error". 2016-08-30 18:55:21 is the right output, or?. Im wondering why the "Query was empty" message was generated because there is a response.

Try: 

$result = mysql_query("SELECT create_time FROM ".SQL_HP_DB.".account WHERE id='".$_SESSION['user_id']."' LIMIT 1") or die(mysql_error());
$row = mysql_fetch_assoc($result);
echo date('F d, Y h:mA', strtotime($row["create_time"]));
// uncommand the following line if you want to debug the return value
// var_dump($row);

If "Query was empty" appears, look in your database if the "create_time" is really set for the given user_id.

Link to comment
  • 0

Try :

$Query = mysql_query("SELECT create_time FROM ".SQL_HP_DB.".account WHERE id = '$_SESSION[user_id]'");
$Fetch = mysql_fetch_array($Query);
$create_time = $Fetch[create_time];

Hidden Content

    Give reaction to this post to see the hidden content.

Hidden Content

    Give reaction to this post to see the hidden content.

Link to comment
  • 0
58 minutes ago, eyormaz said:

Try :

$Query = mysql_query("SELECT create_time FROM ".SQL_HP_DB.".account WHERE id = '$_SESSION[user_id]'");
$Fetch = mysql_fetch_array($Query);
$create_time = $Fetch[create_time];

 

What is the decisive technical difference to my example? And why mysql_fetch_array? You don't need numeric and string keys here - you are using the column name, so its recommanded to use MYSQL_ASSOC.

ps: lower_case ftw ;)

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.