Jump to content

vanquish12

New Members
  • Posts

    7
  • Joined

  • Last visited

vanquish12's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I need to get the time difference between two dates. Here's what I have function getTodayDate(){ $today = date('Y-m-d H:i:s'); return $today; } function checkTimeDifference($previousTime){ $today = $previousTime->diff(new DateTime(getTodayDate())); $minutes = $today->days * 24 * 60; $minutes += $today->h * 60; $minutes += $today->i; return $minutes . ' minutes'; } however it's complaining about the call to diff "Call to a member function diff() on a non-object"
  2. thanks for your help guys! I created a databaseConnect() function and I'm using that.
  3. thanks guys I'll give it a try, one more thing, my database connection details are in another file called mysql.php. I've added require("mysql.php"); to the top of the file however the $conn variable (which is set in the mysql.php file) is not being picked up by the function. Is there any way to pass this variable into the function or do I need to provide the connection details in every function which has to do something with the database?
  4. thanks, can I also include an mysql insert statement in the 2nd function so it would look like: function function2($a, $b, $c) { $table = "some table"; $fsock = fsockopen($a, $b, $c); if (!$fsock) { $res= 0; return $res; } else { $res= 1; return $res; } mysqli_query($conn, "INSERT INTO $table (a, b) VALUES ('" . $a . "', '" . $b. "') or die(mysqli_error($conn)); }
  5. function function1(){ $sql = "SELECT a, b, c, d FROM someTable"; $result = mysqli_query($conn, $sql) or die(mysql_error()); if(mysqli_num_rows($result) > 0) { //output data while($row = mysqli_fetch_array($result)) { $row = array_map("function2", $row['a'], $row['b'], $row['c']); } } mysqli_close($conn); } function function2($a, $b, $c) { $table = "some table"; $fsock = fsockopen($a, $b, $c); if (!$fsock) { $res= 0; return $res; } else { $res= 1; return $res; } }
  6. Is it possible to call a function from another function and update a mysql database using the 2nd function? So if I have 1 function which selects data from a database and puts it into an array, I then need the 2nd function to do some stuff and insert the results to another table. Can the insert statement be in the 2nd function or does it have to be a seperate statement?
×
×
  • Create New...

Important Information

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.