Jump to content

PHP - Problem with select time from DB


Recommended Posts

  • Active Member

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

I'll be always helpful! 👊 

Link to comment
Share on other sites

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
Share on other sites

  • Active Member
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.

I'll be always helpful! 👊 

Link to comment
Share on other sites

  • Active Member
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:

I'll be always helpful! 👊 

Link to comment
Share on other sites

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
Share on other sites

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
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

Announcements



  • Similar Content

  • Activity

    1. 5

      Effect weapons

    2. 3

      Crystal Metinstone

    3. 3

      Feeding game source to LLM

    4. 113

      Ulthar SF V2 (TMP4 Base)

    5. 3

      Feeding game source to LLM

    6. 0

      Target Information System

    7. 3

      Feeding game source to LLM

    8. 2

      anti exp explanation pls

  • Recently Browsing

    • No registered users viewing this page.
×
×
  • Create New...

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.