
transfield
Members-
Posts
19 -
Joined
-
Last visited
Everything posted by transfield
-
php MySQL Query Works in PHPMyAdmin But Doesn't Work in a PHP File
transfield replied to transfield's topic in PHP Coding Help
Thanks a lot. It worked 🙂 happy new year to you 🙂 -
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.
-
Yes, that is part of the plan. The main idea is to grab multiple csv files of different names from the same website. The difference in the file names are reflected in the $report and $district variable. For example, I want to grab the following files:- http://thewebsite.com/export.aspx?type=csv&report=salesreport~1~ http://thewebsite.com/export.aspx?type=csv&report=employeereport~2~ http://thewebsite.com/export.aspx?type=csv&report=productionreport~3~ From the above example, salesreport, employeereport and productionreport are stored in the report column of the database. 1,2,3 are stored in the district column of the database.
-
Hi, I'm using the following code to grab a csv file from one website & keep it on my website. The code is working fine. <?php $url = 'http://thewebsite.com/export.aspx?type=csv&report=nameofthereport~8~'; $path = '/home/path/to/mywebsite.com/public_ftp/incoming/nameofthereport_Area_8.csv'; $fp = fopen($path, 'w'); $ch = curl_init($url); curl_setopt($ch, CURLOPT_FILE, $fp); $data = curl_exec($ch); curl_close($ch); fclose($fp); ?> Here's what I want to do next. I want to query a database, and replace nameofthereport and 8 with the results of the query. My code to query the database is below. <?php include("/home/path/to/mywebsite.com/public_html/db_connect.php"); //connect to the database $today = date('Y-m-d'); $query1=("SELECT * FROM `table_name` WHERE expiry > $today"); $result1=mysqli_query($GLOBALS["___mysqli_ston"], $query1); $num1=mysqli_num_rows($result1); if ($num1 > 0) { while ($data = mysqli_fetch_array($result1)){ $email_to = $data["email"]; $district = $data["district"]; $report = $data["report"]; } } ?> Based on the code above, I would like to replace nameofthereport with $report and 8 with $district Could you show me the code please? Thanks.
-
Query a MySql Database & Insert Results As a HTML Meta Tag
transfield replied to transfield's topic in PHP Coding Help
Good advice regarding the hiding of errors using @. I appreciate that, thanks. With regards to keyword stuffing, I plan to "stuff" it with a maximum of 7 keywords. I don't think that's a bad thing to do...correct me if I'm wrong. Why dynamic? Well here's a weird (& probably a warped) idea I have. I'm tracking organic keyword searches from Google which resulted an actual click to my site. I reckon that if the user clicked on my link displayed by Google during an organic search, then that keyword must have: 1. Appeared on the 1st few pages of Google (which means that I am ranking very well for this keyword). 2. My website was very relevant to the needs of the user (otherwise he wouldn't have clicked my link displayed on Google's search results). Is there a better way to identify a good quality meta keyword that this? -
Hi, This is my code. <?php include("/home/path/to/my/website/db_connect.php"); //connect to the database $result2 = mysqli_query($GLOBALS["___mysqli_ston"], "SELECT * from `wp2_search_queries` WHERE (`query` NOT LIKE '%:%') AND (`query` NOT LIKE '%+%') AND (`query` NOT LIKE '%\.%') AND (`query` NOT LIKE '%\'%') AND (`query` NOT LIKE '%\?%') AND (`source` NOT LIKE '%mywebsite.com%') GROUP BY `query` order by `query_date` DESC limit 0,7"); while($rows2=@mysqli_fetch_array($result2)){ $keywords = "{$rows2['query']}".","; echo $keywords; } ?> Now, I want to insert $keywords into the following HTML meta tag: <meta name='keywords' content='<?php echo $keywords;?>'> How do I get the 'final product' to look like this? <meta name='keywords' content='keyword1,keyword2,keyword3,keyword4,keyword5,keyword6,keyword7'> Please show me the code as I may not be able to understand your instructions. Thanks
-
Never mind. You never answered any of my questions anyway. You were more interested in deviating from the original issue for reasons best known to you.
-
I want all the search results to go into this line: if($user_data -> user_login === 'admin' || $user_data -> user_login === 'joe'){
-
I've figured out the 1st part which is: <?php global $wpdb; $my_table = $wpdb->prefix."users"; $my_query = "Select user_login from $my_table where user_login LIKE '%z%' "; $my_results = $wpdb->get_results($my_query); ?> Now, in second part, how do I put the search results into the foreach loop? Lets assume that I have 100 records in the search results. How do I loop through all the 100 records using the code below: <?php foreach($my_results as $user_data) { if($user_data -> user_login === 'admin' || $user_data -> user_login === 'joe' //all hundred records need to go inside here. How do I do that?) // do something } ?> Thanks for your help.
-
Hi, I have a Wordpress plugin which I want to edit. My code is below. I have made comments in the areas that I need help in coding. I would appreciate your assistance in showing me the correct way to write the code. Thanks <?php global $wpdb; //this should be correct //I need help to convert the 2 lines below to a Wordpress friendly query $query1="SELECT * FROM wp_users WHERE user_login LIKE '%z%'"; $result1 = mysql_query($query1); //I want to put the search results into the example below if ( $user_login == 'admin' || $user_login == 'joe' ) { $do_something; } ?>