-
Posts
24,603 -
Joined
-
Last visited
-
Days Won
830
Everything posted by Barand
-
strategies to prevent spamming out of PHP emails
Barand replied to ajetrumpet's topic in PHP Coding Help
If there were such a thing, every spammer would be using it. -
issues in WP-parallax-theme Twenty Seventeen the free parallax theme
Barand replied to dil_bert's topic in Applications
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> -
"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.
-
I also you suggest you check the manual for PDOStatement::execute() to see what it returns.
-
The SQL tutorial link in my signature below may be of some use. It is based on a fictional school.
-
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 )
-
Pity. If you had read on you'd have seen he is writing to a text file.
-
Turn your error reporting ON
-
BTW, that line you added is missing a ";" from the end;
-
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.
-
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?
-
capturing multiple checkboxes' names when submitting form
Barand replied to ajetrumpet's topic in PHP Coding Help
I'm curious to know how that posted code outputs any settings with "off" (unchecked checkboxes aren't posted) -
+----------------+ +----------------+ | 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 |<----------+ +----------+
-
Plus a couple of related sections... Handling file uploads Uploading multiple files
-
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);
-
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.
-
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.
-
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?
-
This time, read what I said.
-
Need help with functions.php file on my wordpress site
Barand replied to kiko12122's topic in PHP Coding Help
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. -
Need help with functions.php file on my wordpress site
Barand replied to kiko12122's topic in PHP Coding Help
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 }