Answer by andrewsi for Wordpress Double Title In header - No seo plugins
You've got two calls that look like they're duplicated. Inside the PHP block in the <title> tag, you're calling: wp_title( '|', true, 'right' ); Accord to the documentation, this will return the...
View ArticleAnswer by andrewsi for Wordpress: Unlimitet Posts on specific Page
You can over-ride the settings from the admin page programmatically. You're going to need to tweak your query, though, and over-ride the loop. I think something like this will work: global $wp_query;...
View ArticleAnswer by andrewsi for Wordpress wp_query taking a long time
One thing you can do is tweak the tax_query parameter; you're joining the same table six times, and each one has an IN statement - that's producing some very inefficient SQL, as you've noticed. The...
View ArticleAnswer by andrewsi for Wordpress category query not working
You're almost there. Have a look at the manual page for single_cat_title(), you'll see that it takes two parameters. The first is a prefix to use in the return; the second is the important one here -...
View ArticleAnswer by andrewsi for Getting an error of SQl Syntax
$sql = mysqli_query($conn,"INSERT INTO forgot(userid,email,mobile)VALUES ('$userid','$email','$mobile')"); if (mysqli_query($conn,$sql)) { echo "We will Contact you Soon.<br>"; } You've got two...
View ArticleAnswer by andrewsi for populate html table with php from mySQL based on user...
$sql = "SELECT test1,'$montreal' AS testX FROM test WHERE test1='$zurich'"; Mark's answer is correct, but not for the reason he gives. He says that the above will treat '$montreal' as a string literal....
View ArticleAnswer by andrewsi for php/ mysql - Sending multiple data to MySQL
There are a couple of linked issues here. Your cart function is effectively: function cart() { //print some stuff foreach($_SESSION as $name => $value) { if (empty($total)) { if (empty($sub)) { //do...
View ArticleAnswer by andrewsi for How to validate if it's an authorised user sending a...
Without knowing how your authentication works, it's a little difficult to say. When I've had to do this in the past, I've used a combination of server-side authentication to identify the user sending...
View ArticleAnswer by andrewsi for Deleting a selected record in an HTML form with a...
$st=$object->prepare("delete * from banners where bannerid IN (?)"); $st->bindParam(1, $ids); You're trying to bind a single parameter to an array of values. You need to pass in each value as a...
View ArticleAnswer by andrewsi for loop failing to break out upon validation
break will break out of the loop that you're currently in; a simplified version of your code is: for ($x = 0; $x <= 5; $x++){ foreach($decoded as $value) { if(!empty($ipdv6)){ break; } } } So your...
View ArticleAnswer by andrewsi for Wordpress: wpdb prepare with conditional variable
It looks like you can pass an array to prepare, as well as a list of variables, according to the WordPress documentation That means that you could do something like this: $where = ""; $parameters =...
View ArticleAnswer by andrewsi for Unsure what PHP array is doing upon assigning
Your two assignments are doing two subtly different things. while ($stmt->fetch()) { $data[$ddp][0] = $row[0]; $data[$ddp][1] = $row[1]; $ddp++; } This creates two entries in the array - the first...
View ArticleAnswer by andrewsi for How to get last inserted inserted row id from PDO
You're almost there. If you look at the manual page for lastInsertId, it's called on the database handle - you're currently calling it on the statement. You just need to call:...
View ArticleAnswer by andrewsi for Anagram Algorithm in PHP
(I'm adding this as a separate answer, as it's a different way of dealing with the issue than I mentioned in my first issue) This is a more complex way of working out which words in the dictionary are...
View ArticleAnswer by andrewsi for User Active Check
The issue is here: $userRow=$stmt->fetch(PDO::FETCH_ASSOC); if($userRow == '0'){ You're getting an associative array back from fetch, and comparing it with 0 on the next line. Instead, you want to...
View ArticleAnswer by andrewsi for Displaying multiple rows in PhP
There are a few things wrong with your code: $query = "SELECT * FROM hotel"; $results = $conn->query($query); $hotel = $results->fetch(); At this point, you've loaded the first record into...
View ArticleAnswer by andrewsi for Why do Wordpress code consistently have the uncommon...
There's an explanation on the WordPress site: https://make.wordpress.org/core/handbook/best-practices/coding-standards/php/#yoda-conditions It's called Yoda conditions; in short, it's because it's very...
View ArticleAnswer by andrewsi for Extended class instance cannot access the injected...
I think you're misunderstanding how objects work. class dog { public $id = 0; public function __construct($attributes = array()) { foreach($attributes as $field=>$value){ $this->$field = $value;...
View ArticleAnswer by andrewsi for php - xml parser Notice: Trying to get property of...
If it works with integers, but not with strings, you probably just need to quote your variable in your query: $result2= $xpath2->query('/root[@name="gf"]/node1[@id="'. $id2.'"]');
View ArticleAnswer by andrewsi for Display different content depending on Referrer
Your logic is slightly skewed; you're checking to see if the URL from parse_url matches the domains in your array; but you're running through the whole array each time. So you get both a match and a...
View Article