Jump to content

MySQL Query Works in PHPMyAdmin But Doesn't Work in a PHP File


Go to solution Solved by Barand,

Recommended Posts

Hi, this query runs fine when I run it from PHPMyAdmin:
 

UPDATE `tran_term_taxonomy` SET `description` = (SELECT keyword from `good_keywords` ORDER BY RAND() LIMIT 1,1) WHERE `tran_term_taxonomy`.`taxonomy` = 'post_tag' AND `tran_term_taxonomy`.`description` = "" LIMIT 1

However, when I run the same query in a PHP file on my server, the page doesn't load at all. The message I get is: www.somesite.com is currently unable to handle this request. HTTP ERROR 500. This is my PHP code:

<?php 
include("/database/connection/path/db_connect.php"); 

$result4 = mysqli_query($GLOBALS["___mysqli_ston"], "UPDATE `tran_term_taxonomy` SET `description` = (SELECT keyword from `good_keywords` ORDER BY RAND() LIMIT 1,1) WHERE `tran_term_taxonomy`.`taxonomy` = 'post_tag' AND `tran_term_taxonomy`.`description` = "" LIMIT 1");
echo $result4;

?>

So how do I make this query work please? Thanks for your guidance.

  • Solution

Try changing the

`tran_term_taxonomy`.`description` = ""

to

`tran_term_taxonomy`.`description` = ''

It won't like you using " in a string enclosed by ".."

  • Like 1
On 12/29/2020 at 10:43 PM, Barand said:

Try changing the


`tran_term_taxonomy`.`description` = ""

to


`tran_term_taxonomy`.`description` = ''

It won't like you using " in a string enclosed by ".."

Thanks a lot. It worked 🙂 happy new year to you 🙂

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.