Jump to content

transfield

Members
  • Posts

    19
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

transfield's Achievements

Member

Member (2/5)

0

Reputation

  1. Thanks a lot. It worked 🙂 happy new year to you 🙂
  2. 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.
  3. 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.
  4. 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.
  5. 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?
  6. 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
  7. 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.
  8. I want all the search results to go into this line: if($user_data -> user_login === 'admin' || $user_data -> user_login === 'joe'){
  9. 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.
  10. 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; } ?>
  11. Hi, I am currently using the results of one query to query another table. I'm looking for a simple solution to combine both these queries into a single query & achieve the same result. Part of my code is below. Could you please help me to re-write my query? Thanks. $query1=("SELECT * FROM test_log WHERE '$mktime' < expiry ORDER BY id DESC"); $result1=mysql_query($query1); $num1=mysql_num_rows($result1); while ($row1 = mysql_fetch_array($result1)) { $id = $row1["id"]; $keyword = $row1["keyword"]; $sale = $row1["sale_rent"]; $agents = $row1["e_num"]; $email = $row1["email"]; $cc_email = $row1["cc_email"]; $expiry = $row1["expiry"]; $query2= ("SELECT * FROM condo WHERE (location LIKE '%{$row1['keyword']}%' AND sale_rent LIKE '%{$row1['sale_rent']}%' AND e_num LIKE '{$row1['e_num']}') AND (date >= '$sendate') AND TRIM(IFNULL(`phone_1`,'')) <> '' ORDER BY sale_rent, location"); $result2=mysql_query($query2); $num2=mysql_num_rows($result2); From the code above, I am using the results of $query1 to query the condo table ($query2). So now I want to do away with two queries & have just one query to achieve the same results. Could you show me the code please? Thanks
  12. Hello, I'm hosting my website on a Linux server. My web host gives me unlimited email accounts. I access my emails using either Horde or Squirrel Mail which is provided to me by my web host as part of my hosting package. I want to import all my incoming emails into a Mysql database. The Mysql database is also provided to me by my web host as part of my hosting package. How do I do that? I am looking for a PHP solution, if possible. I have looked at the control panel provided to me by my web host. There is a feature to 'pipe my emails to a program', whatever that means. A screen shot is attached. Can I use this feature to do what I want to do? If so, how do I do it?
  13. Hello, I have 2 tables. The structures are below:- CREATE TABLE IF NOT EXISTS `dcp_reports_raw` ( `id` int(6) NOT NULL auto_increment, `club_num` int(10) NOT NULL, `club_name` varchar(60) NOT NULL, `mship_base` int(3) NOT NULL, `mship_todate` int(3) NOT NULL, `dcp_todate` int(2) NOT NULL, KEY `id` (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=0; CREATE TABLE IF NOT EXISTS `dcp_reports` ( `id` int(6) NOT NULL auto_increment, `club_num` int(10) NOT NULL, `club_name` varchar(60) NOT NULL, `mship_base` int(3) NOT NULL, `mship_todate` int(3) NOT NULL, `dcp_todate` int(2) NOT NULL, `mship_lastweek` int(3) NOT NULL, `dcp_lastweek` int(2) NOT NULL, `to_email` varchar(100) NOT NULL, `from_email` varchar(50) NOT NULL, `message` varchar(1000) NOT NULL, `database_lastupdated` date NOT NULL, `email_lastsent` date NOT NULL, `expiry` date NOT NULL, KEY `id` (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=0; I want to :- 1. update dcp_reports.mship_todate with the data from dcp_reports_raw.mship_todate provided that the values of dcp_reports.club_num and dcp_reports_raw.club_num are the same. 2. update dcp_reports.dcp_todate with the data from dcp_reports_raw.dcp_todate provided that the values of dcp_reports.club_num and dcp_reports_raw.club_num are the same. If both item 1 and 2 can be combined in 1 query, so much the better. Otherwise, I'm okay with 2 separate queries. Could you show me how to write the code in PHP or MySql please? Thanks.
  14. Hello, I've got 2 websites hosted on 2 different servers. www.a.com is my main site & www.b.com is my so called mirror site. The server on which www.a.com can be quite slow at times. I'm looking for a code(preferably php) that will re-direct my visitors from www.a.com to www.b.com if the pages on the former takes more than 5 seconds to open. I uderstand that fsockopen is supposed to do the job but I don't know how to get it working. How do I achieve this? Thanks.
  15. Hello. I need to know how to write a query. The scenario is below. I've got 2 columns in a Mysql database. The names of the columns are Approved_Year & State. The sample with some records are below:- Approved_Year | State 2006 | Perlis 2006 | Johor 2007 | Kedah 2008 | Perlis 2008 | Perlis 2008 | Kedah I want to count how many records appear for Perlis on a yearly basis. The answer should looks like this:- Year 2006 - 1 records Year 2007 - 0 records Year 2008 - 2 records I know how to connect to the Mysql database & I know how to display the records so we can skip these steps. I just need to know how to write the query. Thanks for your help.
×
×
  • 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.