Querying a wordpress database [closed] - php

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 7 years ago.
Improve this question
Can anyone see whats wrong with this syntax? I've consulted the wordpress codex page and the syntax seems to be correct..
$result = $wpdb->query($wpdb->prepare( "SELECT * FROM {$wpdb->prefix}users WHERE username = %s AND password = %s, array( $username, $password )"));
Thanks

try:
$result = $wpdb->query($wpdb->prepare( "SELECT * FROM {$wpdb->prefix}users WHERE username = %s AND password = %s", array( $username, $password )));
your quotes are incorrect.

Related

How to create a Php multi insertion? [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 3 years ago.
Improve this question
I am trying to prepare an insertion inside the database with php, but i can't find any suggestions on how to use the syntax, this is what I've got so far, could someone help me with this please?
$last_id = mysqli_insert_id($conn);
$query = $conn->prepare("INSERT INTO `table`(name, surname) VALUES (?,?) , (?,?)");
$query->bind_param("ss", ($nameOne, $last_id), ($nametWO, $last_id));
the binding should be
$query->bind_param("ssss", $nameOne, $last_id, $nametWO, $last_id);

DELETE php mysql doesn't work [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 6 years ago.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Improve this question
Hello I have little problem with this:
require_once("dbconnect.php");
mysql_query('set names utf8');
$query = ('DELETE FROM `gallery` WHERE `id` = 16') or die("failed");
It not delete record from DB. Can you help me? Thanks. dbconnect.php is correct.
All you did was declare a variable $query, but you did not run it. You have to run it is $query = mysql_query('DELETE FROM `gallery` WHERE `id` = 16')
Edit: Having said that, do not use mysql_ functions. They allow for SQL injection, which is very dangerous. Instead it is better to use
$mysqli = new mysqli(HOST, USERNAME, PASSWORD, DATABASE);
$query = $mysqli->query('DELETE FROM `gallery` WHERE `id` = 16');

Profile View Update [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 6 years ago.
Improve this question
I am trying to create a query which will update each person's profile views when a member accesses their profile. For some reason it does not update, I am sure it would have worked. Here is my lines:
<?php
$name = $_REQUEST['username'];
$profile = mysql_query("SELECT * FROM users WHERE user_name='$name'");
$uprofile = mysql_fetch_assoc($profile);
$username = $uprofile['user_name'];
$profilev = $uprofile['profile_views'];
mysql_query("UPDATE users SET profile_views +1 WHERE user_name='$name'");
?>
So, On my profile, It displays their username successfully, and it displays the default value of the database for profile_views which ofcourse, is 0. so it is reading correctly, I am just having issues updating the users profile_views.
You have a mistake try
"UPDATE users
SET profile_views = profile_views +1
WHERE user_name='$name'"

PHP PDO Wrong numbers of tokens? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 8 years ago.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Improve this question
Can someone tell me what is wrong with that statement cause I do not see any mistake?
$PrevReleaseModel = $con->prepare("SELECT * FROM model WHERE model_name=:model_name AND model_release:model_release");
$PrevReleaseModel->bindParam('model_name',$model_name);
$PrevReleaseModel->bindParam('model_release',$model_release);
$PrevReleaseModel->execute(array('model_name'=>$model_name,'model_release'=>$model_release));
I am really confused.
WHERE model_name=:model_name AND model_release = :model_release
You missed a equal sign in the last condition.
You may try this out:-
$PrevReleaseModel = $con->prepare('SELECT * FROM model
WHERE model_name = :model_name AND
model_releas = :model_releas'
);
$PrevReleaseModel->bindParam(':model_name', $model_name, PDO::PARAM_STR);
$PrevReleaseModel->bindParam(':model_releas', $model_release, PDO::PARAM_STR);
$PrevReleaseModel->execute();

Bad syntax on MySQL query [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
it says unexpected "="... What should I rewrite? Thanks
$result = mysql_query("SELECT * FROM soubory, users
WHERE id='".$id."'" AND soubory.users_id = users.id );
Remove the second " after $id."'
$result = mysql_query("SELECT * FROM soubory, users WHERE soubory.users_id='".$id."' AND soubory.users_id = users.id");

Categories