Jump to content

Barand

Moderators
  • Posts

    24,603
  • Joined

  • Last visited

  • Days Won

    830

Everything posted by Barand

  1. A DNS lookup converts the domain name you enter into your browser into an ip address. A reverse lookup does it the opposite way round (IP ==> domain name)
  2. If there were such a thing, every spammer would be using it.
  3. Not all server vars are always available. See https://www.php.net/manual/en/reserved.variables.server.php
  4. Use rgba() function to specify background color or specify no background color. Example <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Sample</title> <style type="text/css"> #main { padding: 30px; width: 400px; background-image: url("https://images.pexels.com/photos/207142/pexels-photo-207142.jpeg"); } .inner { display: inline-block; width: 100px; height: 100px; border: 2px solid yellow; font-size: 40px; text-align: center; margin: 10px; } #A { background-color: #80FF80;} /* non-transparent */ #B { background-color: rgba(128, 255, 128, 0.5);} /* semi-transparent */ #C { background-color: none; } /* transparent */ </style> </head> <body> <div id="main"> <div class="inner" id="A">A</div> <div class="inner" id="B">B</div> <div class="inner" id="C">C</div> <div> </body> </html>
  5. "Unexpected end of file" errors occur when the php parser expects something but cannot find it. Usual causes are an opening { without a corresponding closing } or quots at the start of a string and then no closing quotes. You'll have to find it yourself as it's impossible from just the couple of isolated snippets that we can see.
  6. I also you suggest you check the manual for PDOStatement::execute() to see what it returns.
  7. The SQL tutorial link in my signature below may be of some use. It is based on a fictional school.
  8. if I were you I'd use a newline (\n) to separate the data instead of "@@@". if(isset($_POST['textdata'])) { file_put_contents('data.txt', $_POST['textdata']."\n", FILE_APPEND); } Then, if you data.txt file contains, say TESTA TESTB TESTC TESTD ... you can read it back and separate the items into an array using file(); $data = file('data.txt'); giving $data = Array ( [0] => TESTA [1] => TESTB [2] => TESTC [3] => TESTD )
  9. Pity. If you had read on you'd have seen he is writing to a text file.
  10. Turn your error reporting ON
  11. BTW, that line you added is missing a ";" from the end;
  12. In what way is it "not working"? What do you want to happen so you can say it is working? When posting, bear in mind we are not psychic and cannot see your screen and the data values you are seeing.
  13. It's hard to find something that is defined. Your first query selects productcode from products but the value for the options is "productid" The select is named "drpcode" yet you are expecting $_POST[''productid'] What jQuery? What AJAX function?
  14. I'm curious to know how that posted code outputs any settings with "off" (unchecked checkboxes aren't posted)
  15. +----------------+ +----------------+ | Make sure to |---+ +------->| (e.g. Courier) | +----------------+ | | +----------------+ | | | | +----------+ | | +->| use a |---+ | | +----------------+ +----------+ | | +------->| and use spaces | | | +----------------+ | +----------------+ | | +--->| monospace font |-----+ | +----------------+ | +----------+ | | not tabs |<----------+ +----------+ | +--------------------------------------------------------------------------+ | V +---------------+ | It also helps | +---------------+ | | | +-------------------+ +-------------------+ +------------------------>| if you sometimes |---------------------->| switch between | +-------------------+ +-------------------+ | | +-----------------+-----------------+ | | | | +-------------------+ +-------------------+ | overtype | | insert | +-------------------+ +-------------------+ | | | | | +----------+ | +----------=>| modes |<----------+ +----------+
  16. Plus a couple of related sections... Handling file uploads Uploading multiple files
  17. Sorry, there is an error $where = "max_price <= ?"; should be $where[] = "max_price <= ?";
  18. The query has inbuilt syntax errors. Your WHERE clause will always begin with "WHERE AND … " IMO a cleaner way to include conditions only if there is a value is $min_price = 10; $max_price = 50; $featured = 1; $binds = []; $where = []; $whereclause = ''; if ($min_price > 0) { $where[] = "min_price >= ?"; $binds[] = $min_price; } if ($max_price > 0) { $where = "max_price <= ?"; $binds[] = $max_price; } if (in_array($featured, [0,1])) { $where[] = "featured = ?"; $binds[] = $featured ; } if ($where) $whereclause = 'WHERE ' . join(' AND ', $where); $find_records = $db->prepare(" SELECT * FROM projects $whereclause "); $find_records->execute($binds); $result_records = $find_records->fetchAll(PDO::FETCH_ASSOC);
  19. Or you can use ? placeholders. $find_records = $db->prepare("SELECT * FROM projects WHERE min_price >= ? AND max_price <= ? AND featured = ? "); $find_records->execute( [ $min_price, $max_price, $featured ] ); $result_records = $find_records->fetchAll(PDO::FETCH_ASSOC);
  20. If you do it the second way (no placeholders), there is no point in preparing it; just use $db->query(). CAVEAT: If $vars originated from an external source ($_GET, $_POST, $_COOKIE etc) then you are injection-prone and, as you are not even escaping the values your queries could fail. EG $username = "O'Reilly"; $res = $db->query("SELECT password FROM user WHERE username = '$username' ") // fails with syntax error and open to injection If in doubt, prepare(); Your bindings do not either, the query does. The array is just a more convenient way of binding.
  21. Your WHERE clause will then be like this... … WHERE id = N AND duplicate = 'False' You have my sympathy. Also those "Answer_x" columns should ne normalized into a separate table; separate row for each answer.
  22. The thing about programming is that it requires some thought. Why would as user_id be equal to a date value? Why don't you do some reading about how to use SQL instead of taking the "infinite monkeys with typewriters" approach in the hope you eventually come up with a right answer?
  23. This time, read what I said.
  24. PS there is a perfectly good function in php already which does all this for you $file_data = file_get_contents($file); Which reminds me, your function needs to return the file data.
  25. If KB_TO_BYTES has not been defined then you need const KB_TO_BYTES = 1024; // We don't need to write to the file, so just open for reading $fp = fopen($file, 'r'); // open file for reading if ($fp) { $file_data = fread($fp, 8 * KB_TO_BYTES); fclose($fp); //close the file }
×
×
  • 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.