Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
"hat is wrong width this MySql and php construction?
$zapytanie = "UPDATE Users
SET usr_premium_expire = '$data'
WHERE usr_login = '$login';
";
You don't need the semi-colon in the MySQL statement.
If any further error occurs, try
mysql_error();
after you've executed the statement.
To validate the data sent try
echo $zapytanie;
When in doubt also escape the variables:
"UPDATE Users SET usr_premium_expire='" . $data . "' WHERE usr_login='" . $login . "'"
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
$sql4 = "SELECT userid, userName FROM $user_table WHERE userName= '$userNames'";
$result = $conn->query($sql4);
$_SESSION['myUser'] = $result['userid'] ;
I have most code I can find but nothing works
Assuming these lines of code come immediately after executing an insert of a new user record and you are using PDO. You could try:
$last_id = $conn->lastInsertId();
$_SESSION['myUser'] = $last_id;
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I have some code here for a song request program. And it works just fine other than the user has to use surrounding quotes for an exact match. I am wondering how I would go about having the php add the quotes so the user can type a band or song title as normal without having to read the small help notice saying to use quotes?
You can concate quotes in after if you like.
$termToSearch = '"' . $termFromUser . '"';
$query = 'SELECT * FROM table WHERE song = :song'
$statement = $this->db->prepare($query);
$statement->bindValue(':song', $termToSearch);
$statement->execute();
$statement->closeCursor();
Just use "=" instead of "LIKE"
SELECT * FROM table WHERE column = '$searchterm'
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I'm passing a string with AJAX and trying to find the mySQL db entry that contains the string in one of its columns. I think the string passing is OK but perhaps the mySQL code is incorrect?
$id = ($_POST['video_id']);
$text_result = mysql_query("SELECT * FROM `wmtwDB` WHERE `url` LIKE (" . $id . ") LIMIT 1");
LIKE syntax is failing. Try with:
$text_result = mysql_query("SELECT * FROM `wmtwDB` WHERE `url` LIKE %" . $id . "% LIMIT 1");
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
This statement works in pgAdmin but not when run in a php script the php script can select all but can not update why is this?
UPDATE users SET password = '123123' WHERE email = 'random#random.com'
PHP code that doesn't work:
$sql = $dbh->prepare("UPDATE users SET password = '11111111111' WHERE email = 'test#outlook.com')");
$sql->execute(array());
PHP code that does work:
$sql = $dbh->prepare("SELECT * FROM users");
$sql->execute(array());
$fr = $sql->fetchAll(); var_dump($fr);
In your update query you've got ) at the end which will cause syntax error. Check it using eg. $dbh->errorInfo().
Also, don't use prepare() for queries that don't use parameters. Instead use query() for SELECT and exec() for others.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I have a problem with disappearing my mysql_error and 50% of my website under error...
MySQL_Query("UPDATE table
SET use = '1'
WHERE name = '$code'", $SpojenieWeb) or die(mysql_error());
Why it is disaappearing ? Where is the error ?
Why it is disaappearing?
It's disappearing because most probably your UPDATE query fails and you use die() in case of failure.
Now it's really hard to say exactly since you provided not enough information, but looking at you query you at least have to change
"UPDATE table SET use = '1' WHERE name = '$code' ..."
to
"UPDATE `table` SET `use` = '1' WHERE name = '$code' ..."
^ ^ ^ ^
table and use are reserved words in Mysql