Jump to content

transfield

Members
  • Posts

    19
  • Joined

  • Last visited

Everything posted by transfield

  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.
  16. Hello, I want to validate 4 text boxes(in a html form) to prevent users from keying in certain words. I'm using the code below to validate 1 text box & the code works fine. How do I use the same code to validate all 4 text boxes instead of re-writing the code 4 times? [code]if (in_array(strtoupper($_POST['Text_Box_1']), array('03-', '04-', '05-', '06-', '07-', '08-', '09-', '012', '013', '016', '017', '019', 'E10', 'E20', 'E30', 'RM1', 'RM2', 'RM3', 'RM4', 'RM5', 'RM6', 'RM7', 'RM8', 'RM9', '012-', '013-', '016-', '017-', '019-'))) die('This keyword is disallowed. Please click the BACK button of your browser & change your search criteria to something else. Thanks :-)');[/code] The names of my text boxes are:- Text_Box_1 Text_Box_2 Text_Box_3 Text_Box_4 Thanks a lot for your assistance.
  17. Hello, I've got a table called [B]condo03[/B]. In this table there are 3 fields called [B]date[/B], [B]price[/B] & [B]full_add[/B] respectively. I want to:- 1. Query the [B]full_add[/B] field using a keyword that I specify. Then group all the dates together in the [B]date[/B] field. Then calculate the median price in the [B]price[/B] field according to the individual date groups. As such, if there are 10 different dates in the date field, then there should be 10 groups created & 10 different median prices generated. I've written the code below to the best of my ability & I hope that you can edit it for me. The part that is not working is the calculation of the median price according to individual date groups. At present it is calculating the median in total regardless of the number of date groups. Thanks a lot for your help. [code=php:0]<?php $query1=("SELECT price FROM condo03 WHERE (full_add like '%$Text_Box_1%' OR full_add like '%$Text_Box_2%' OR full_add like '%$Text_Box_3%' OR full_add like '%$Text_Box_4%') AND (status = '$status') AND (size >= '$Text_Box_15' AND size <= '$Text_Box_16')"); //$query2 is working fine. $query2=("SELECT distinct(date), COUNT(date) AS count FROM condo03 WHERE (full_add like '%$Text_Box_1%' OR full_add like '%$Text_Box_2%' OR full_add like '%$Text_Box_3%' OR full_add like '%$Text_Box_4%') AND (status = '$status') AND (size >= '$Text_Box_15' AND size <= '$Text_Box_16') GROUP BY 'date' ASC"); $result1=mysql_query($query1); $num1=mysql_num_rows($result1); $result2=mysql_query($query2); $num2=mysql_num_rows($result2); //the median calculation starts here. The code works fine. $thearray=array(); while ( $row=mysql_fetch_array($result1,MYSQL_NUM) ) { $thearray[]=$row[0]; } $num0=count($thearray); if ($num0 % 2) { $median = $thearray[floor($num0/2)]; } else { $median = ($thearray[$num0/2] + $thearray[$num0/2 - 1]) / 2; } //The median calculation ends here. while ($row2 = mysql_fetch_assoc($result2)){ ?> <table border="1" cellspacing="2" cellpadding="2"> <tr> <td style="border-style: solid; border-width: 1" bgcolor="#CCFFFF" align="left" width="165"><b><div align="center"><font size="4" face="Arial, Helvetica, sans-serif"><? echo "$row2[date]"; ?></font></div></td> <td style="border-style: solid; border-width: 1" bgcolor="#CCFFFF" align="left" width="165"><b><div align="center"><font size="4" face="Arial, Helvetica, sans-serif"><? echo "$median"; ?></font></div></td> <td style="border-style: solid; border-width: 1" bgcolor="#CCFFFF" align="left" width="165"><b><div align="center"><font size="4" face="Arial, Helvetica, sans-serif"><? echo "$row2[count]"; ?></font></div></td> </tr> </table> <?php } ?>[/code]
  18. Hello, I have 2 tables in 1 database. The table names are developer and developer_log. I want to use the keywords in developer_log to query developer. Then I want to display the results of this query. So here's how it should work:- developer_log.company should query developer.name developer_log.project should query developer.development developer_log.property should query developer.type My half written code is below. Please help me to modify it. Thank you very much. [code]<?php $username="abc123"; $password="abc123"; $database="abc123"; $host="localhost"; mysql_connect ("$host","$username","$password"); mysql_select_db($database) or die( "Where's the database man?"); $mktime = date('Y-m-d'); $query1=("SELECT * FROM THIS IS WHERE I NEED HELP, I GUESS"); $result1=mysql_query($query1); $num=mysql_num_rows($result1); while ($row1 = mysql_fetch_array($result1)) { echo"<b>Year Approved: </b> ".$row1['year']. "<p><b>Name of Developer: </b> ".$row1['name']. "<p><b>Address: </b> ".$row1['development']. "<p><b>Type of Property: </b> ".$row1['type']. "<p><b>Levels: </b> ".$row1['levels']. "<p><b>Number of Units: </b> ".$row1['quantity']. "<p>" ; } ?>[/code]
  19. Hello, I'd like to track the surfing activities of people who visit my website. I'd like to start tracking their activities the moment they log in. I have a login page in which they need to enter their username & password. Once they have logged in, they will be able to use the various features on my website which are behind the login page(password protected & have sessions).The people may browse from page to page & I'd like to capture all their activities on every page. I have created a table in my MySql database with fields like date, time, id(a unique autonumber that identifies a person), etc. This table is supposed to capture all the surfing activities of the people. Apart from that, I don't know where to start & what else to do. Could you advice me what to do. I'm a newbie who does not understand much technical jargon. Thanks.
×
×
  • 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.