Jump to content

BrainPill

Members
  • Content Count

    45
  • Joined

  • Last visited

Community Reputation

1 Neutral

About BrainPill

  • Rank
    Newbie

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. I solved this meanwhile by changing the $browser variable into $some_var as I assume $browser is a reserved variable by php
  2. I have browscap installed this way: X:/wamp64/browscap/lite_php_browscap.ini If I use the following code: <?php $browser = get_browser(null, true); var_dump($browser); $brows_par = $browser['parent']; $browser = $browser['browser']; $version = $browser['version']; $platform = $browser['platform']; $dev_type = $browser['device_type']; $mobile = $browser['ismobiledevice']; $tablet = $browser['istablet']; ?> Then I get error messages for the last 5 variable settings error output: and for the other offsets same error message except the first 2. see the image for the var_dump value of $browser what causes the Illegal String Offset warning error message?
  3. I also solved it for batch files, by removing the parentheses
  4. I made a type mismatch in PHPmyadmin. The ; should not be included inside the double quotes. But still I can't understand the change of : - into a : û in the batch script. What causes this error?
  5. I solved this meanwhile. I used the timestamp column to make the query . I used this query : DELETE FROM `tab` WHERE `timestamp_col` < (NOW()– INTERVAL 10 MINUTE); I works only in the mysql command line interpreter. But I cant get it working in a batch script. Also in phpmyadmin it does not work. The error is in the minus sign. when running the batch script it shows a u with a caret like this û , and phpmyadmin gives error messages. Anyone any idea how to solve this?
  6. I also have a changed_on column with a timestamp value, is that also possible to use for the problem above?
  7. I want to have a mysql command that deletes a row based on the present time value. For example the column is like: first_time = 1550566437 (the time in the table.column is based on time() in php.) I would like to delete the rows that are older than one hour from the present time. I want to use mysql to delete it. My idea is that you can use now() from mysql and determine the difference in seconds (3600) Is that possible and how is it done?
  8. PHP does not give any errors. Or can I see it in phpmyadmin? This is the intended php/mysql code from the function I made. <?php // make OOP mysqli database connection $sql = 'SELECT Table_Name FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = `yourdatabase_db` AND COLUMN_NAME LIKE `user_id` '; $stmt = $conn->prepare($sql) ; var_dump($stmt); $stmt->execute(); var_dump($stmt); //$stmt->bind_result($tabs); while ($stmt->fetch()) { var_dump($tabs); } printf("Error: %s.\n\r", mysqli_stmt_error($stmt)); printf("Error: %d.\n\r", mysqli_stmt_errno($stmt)); printf("Error: %s.\n\r", mysqli_stmt_sqlstate($stmt)); ?>
  9. I would like to fit this specific mysl query into php. I use prepared statements OOP for most queries if possible. Is there a way to get this executed: // database connection $sql = 'SELECT Table_Name FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = `my_database` AND COLUMN_NAME LIKE `my_column` '; // do OOP prepared statements to get the columns I tried the mysql code in phpmyadmin and it worked properly, but in PHP no output. Please help.
  10. I meanwhile solved this by using var_export(). The output then is an exact render of the array in php.
  11. I would like to write the values of an array to a php file. I use fopen/fwrite/fclose to write the php file. I can define the array like this: But I get an array to string conversion error when the file is created. <?php $pagename = 'testpage2018a'; $data = 'abcd987654'; $fruit = array('apples','bananas','grapes'); $var5 = '$data'; $var6 = '$fruit'; $fopenvar = fopen('F:/www/yourdirectory/test/'.$pagename.'.php', 'w'); $page_cont = " <html> <body><center> <?php $var5 = '" . $data . "'; var_dump($var5); $var6 = '" . $fruit . "'; var_dump($var6); ?> </center> </body> </html> ?> How to solve this and write an array to a php file?
  12. Sorry I do not get it. Do you try to say that I need $_SESSION variables to make a website visitor unique? I suppose it is possible to store a user_id in a session var called $_SESSION['user_id'] = '12345abc'; but are you trying to say this is the proper solution for tracking website visitors? If an ipnumber has multiple devices connected to this single ipaddress I will not be able to distinguish them correctly. My assumption is that a browser cookie gives that possibility and for that reason I want to extract them.
  13. If I make a session cookie en store this in the database and I want to compare this database value with the value in the browser of the client, which kind of code do I need then to read the session cookie from the browser ? It is for a visitor counter. I don't know where to start exactly. Are there more possibilities? When I google it I get SE results telling that I have to use request headers in combination with CURL. I am not really familiar with it, so what is the best set up? I am building a visitor counter and besides ip number I would like to use a unique session_id alphanumeric that lasts until the user removes the cookie. Assuming this is the proper procedure I would like to figure out how it works and what code is used. Or is there an easier way to do this?
  14. I got that. It works terrific. Thanks for helping me out .
  15. This question is based on the table and class set up in my former posting. The difference is that I want to have a second function inside the class. The name of this second function is: check_amount () . I do not see any output or action at all in this function. I hope someone can help to make the example work. Database table: -- phpMyAdmin SQL Dump -- version 4.7.4 -- https://www.phpmyadmin.net/ -- -- Host: localhost:3306 -- Generation Time: Oct 04, 2018 at 08:42 AM -- Server version: 5.7.19 -- PHP Version: 7.1.9 SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; SET AUTOCOMMIT = 0; START TRANSACTION; SET time_zone = "+00:00"; /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; /*!40101 SET NAMES utf8mb4 */; -- -- Database: `test_fruit` -- -- -------------------------------------------------------- -- -- Table structure for table `fruit` -- DROP TABLE IF EXISTS `fruit`; CREATE TABLE IF NOT EXISTS `fruit` ( `rec_nr` int(2) NOT NULL AUTO_INCREMENT, `fruit_type` varchar(50) DEFAULT NULL, `amount` int(3) NOT NULL, `created_on` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `changed_on` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`rec_nr`,`created_on`,`changed_on`) ) ENGINE=MyISAM AUTO_INCREMENT=5 DEFAULT CHARSET=latin1; -- -- Dumping data for table `fruit` -- INSERT INTO `fruit` (`rec_nr`, `fruit_type`, `amount`, `created_on`, `changed_on`) VALUES (1, 'apple', 5, '2018-10-04 06:01:48', '2018-10-04 06:01:48'), (2, 'strawberry', 20, '2018-10-04 06:01:48', '2018-10-04 06:01:48'), (2, 'banana', 15, '2018-10-04 06:02:54', '2018-10-04 06:02:54'), (4, 'grapes', 9, '2018-10-04 06:02:54', '2018-10-04 06:02:54'); COMMIT; /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; Script 1: <?php $amount = '' ; // 5, 20 , 15, 9 $fruit_type = 'grapes'; // grapes , apple, strawberry, banana $dbname = "test_fruit"; include 'fruit-class4a.php'; $object = new fruit_stock( '$fruit_type','$dbname'); $object -> get_fruit($amount, $fruit_type, $dbname); // $object ->get_fruit($amount, $fruit_type, $dbname)->check_amount($amount); var_dump($object); echo $object -> get_fruit($amount, $fruit_type, $dbname); ?> Script 2: <?php class fruit_stock { var $amount; var $dbname; public function get_fruit($amount, $fruit_type, $dbname) { global $amount; var_dump($fruit_type); var_dump($dbname); include 'login-test.php'; // login credentials $conn = new mysqli($servername, $username, $password, $dbname); if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } // PREPARED if ($stmt = $conn->prepare("SELECT amount FROM fruit WHERE fruit_type = ? ; " )) { $stmt->bind_param('s', $fruit_type); // $stmt->execute(); $stmt->bind_result($amount); while ($stmt->fetch()) { var_dump($amount); return $amount; } } } public function check_amount($amount) { $amount = $amount + 1; var_dump($amount); return $amount; } } ?>
×
×
  • Create New...