Jump to content

jazzman1

Staff Alumni
  • Posts

    2,713
  • Joined

  • Last visited

  • Days Won

    12

Everything posted by jazzman1

  1. Then, no need to use a "JOIN" as I thought before, because there is no relationship between them. All you need to do is select the results of those two tables combaining them in one query. // instead //otherwise, get emails from subscribers list $sql = "SELECT email FROM subscribers"; $result = mysqli_query($mysqli, $sql) or die(mysqli_error($mysqli)); //create a From: mailheader $mailheaders = "From: webmaster@1066cards4u.co.uk>"; //loop through results and send mail while ($row = mysqli_fetch_array($result)) { //$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test $mail->AddAddress($row['email']); $mail->SetFrom('administrator@1066cards4u.co.uk', 'Tony Hudson'); } $sqlmail = "SELECT subtxt, message, attachment FROM mail_info WHERE EID= '".$_POST['Eno']."'"; $mailresult = mysqli_query($mysqli, $sqlmail) or die(mysqli_error($mysqli)); while ($rowm = mysqli_fetch_array($mailresult)) { $mail->Subject($rowm['subtxt']); $mail->MsgHTML($rowm['message']); $mail->AddAttachment($rowm['attachment']); // attachment // to be //otherwise, get emails from subscribers list $eno = intval($_POST['Eno']); $sql = "SELECT s.email, m.subtxt, m.message, m.attachment FROM subscribers s, mail_info m WHERE EID = $eno"; $result = mysqli_query($mysqli, $sql) or die(mysqli_error($mysqli)); //create a From: mailheader $mailheaders = "From: webmaster@1066cards4u.co.uk>"; //loop through results and send mail while ($row = mysqli_fetch_array($result)) { //$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test $mail->AddAddress($row['email']); $mail->SetFrom('administrator@1066cards4u.co.uk', 'Tony Hudson'); $mail->Subject = $row['subtxt']; $mail->MsgHTML($rowm['message']); $mail->AddAttachment($rowm['attachment']); // attachment
  2. Is it allowed for users to subscribe to your site with empty email? Is it allowed they to have more than 1 email?
  3. Most likely he wants to implement something similar to quota policies for users/members by using php, but not entirly sure
  4. Infinity loop I see here and very bad, out of date coding design <?php $min = 1; $max = 10; for(;$min<=$max;) { echo $min.' - '. $max; }
  5. B/s the main purpose of using XDebug is to brake down your script into small pieces and fragments of data making it much more easy to debuging. By using OO design patterns, that's guarantee (in most cases) that, that data it's encapsulating within a set of functions designed to ensure that the scripts are used appropriately and in a human readable format.
  6. Turn error reporting on, it would help.
  7. Out of curiosity because I've never used php to setup a limit size for some particular directory. Where is the script to do this?
  8. Afaik from the windows users coming here and using a php mail function, the easiest way is to set up a remote connection between your local machine and some external mail server as gmail, yahoo, so on. Because to send or receive emails you need to have a mail server with mail account itself. By default the windows system ( when I used to actively it was about more than 13 years) didn't come with a copy of mail server software inbuilt itself, but time has been changed. The best way is to check docs of your windows version.
  9. Guys, never ever bother the php parser to parse html/css/js or other client side code especially if the content is large. There is a lot of disadvantages coding in that way, one of this is about the performance.
  10. "To find" is not the right expression when we're tallking about a programming! You need to re-write the scripts yourself understanding 100% of every single tag of your code or just to hire some programmer knowing enough programming to do this job for you.
  11. I find XDebug as not very efficient for myself when I follow object oriented design patterns in my code. It could be very powerful and useful if you're coding in procedural way with bad coding design. I am on Netbeans IDE which is absolutely enough for what I want to do and Vi/VIM as command line interface code editor.
  12. In addition what .josh said, also check into php.ini file whether you're able to use open php short tags for that php's version, or just change /* line 73 */ from <? to <?php PS: I also see prospective depricated php functions in your script in case you want to use php 5.4+ version, you need to replace them.
  13. Yes, everything will be the same except the performance. However, to provide a "JOIN" help, we need to know the structure of "subscribers" and "mail_info" tables.
  14. What environment are you on, Unix or Windows?
  15. Why do you want to mix up a mail library such as phpmailer with a core sendmail?
  16. Why don't you open a new thread instead extend this one? Nobody can charge you to create a new topic.
  17. According the docs, a FROM clause is an optional in MySQL and ONLY a table reference, no database, nor column. In his example above I see a column reference.
  18. Also, I'm not realy sure is it possible to use more than one period(.) as separate table/column identifiers like in the example: FROM SysproCompanyJ.dbo.InvWarehouse as invW
  19. For gurus! MySQL follows the SQL standart using CHARACTER_LENGTH() and its aliases like CHAR_LENGTH() and LENGTH(). LEN() isn't a part of MySQL string functions PS: No need to substring same result twice b/s is already done in the select SELECT substring(invW.StockCode, 1, (len(invW.StockCode) - 1)) as sStockCode, SUM(invW.QtyOnHand - invW.QtyAllocated) AS 'Value' FROM SysproCompanyJ.dbo.InvWarehouse as invW WHERE Warehouse = 'SW' GROUP BY substring(invW.StockCode, 1, (len(invW.StockCode) - 1)) HAVING Value > 0 // to SELECT SUBSTRING(invW.StockCode, 1, (LENGTH(invW.StockCode) - 1)) as sStockCode, SUM(invW.QtyOnHand - invW.QtyAllocated) AS 'Value' FROM SysproCompanyJ.dbo.InvWarehouse as invW WHERE Warehouse = 'SW' GROUP BY sStockCode HAVING Value > 0
  20. Open up the mysql command line and connect to the db server. Then, execute a sql file using the "source" command. // Example, If you're on unix environment mysql> sorce /path/to/schema.sql; // on windows mysql> SOURCE C:/path/to/schema.sql;
  21. Without update the column?
  22. What db tool are you using to import the dump file?
  23. No need to mark anything to used or not, just create a second table which map all rows from the main table. Because it is 3:00 AM and I have to go to work in 5 hours my example will be simple and fast. Create two tables - proxy and proxyMap. CREATE TABLE `proxy` ( `proxy_id` int(10) unsigned NOT NULL AUTO_INCREMENT, `proxy_ip` varchar(45) NOT NULL, PRIMARY KEY (`proxy_id`) ) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8; // insert values INSERT INTO `proxy` VALUES (1,'123.123.123.1'),(6,'123.123.123.2'),(3,'123.123.123.3'),(4,'123.123.123.4'),(5,'123.123.123.5'); // result of select statement mysql> select * from proxy; +----------+---------------+ | proxy_id | proxy_ip | +----------+---------------+ | 1 | 123.123.123.1 | | 2 | 123.123.123.2 | | 3 | 123.123.123.3 | | 4 | 123.123.123.4 | | 5 | 123.123.123.5 | +----------+---------------+ 5 rows in set (0.00 sec) // create proxyMap tbl CREATE TABLE `proxyMap` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `proxy_id` tinyint(3) unsigned NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8; // select proxyMap mysql> select * from proxyMap; Empty set (0.00 sec) Then do an update to proxyMap: UPDATE test.proxyMap SET proxyMap.proxy_id = case proxyMap.proxy_id WHEN (SELECT COUNT(proxy.proxy_id) FROM test.proxy WHERE 1) THEN 1 ELSE proxyMap.proxy_id + 1 END mysql> select * from proxyMap; +----+----------+ | id | proxy_id | +----+----------+ | 1 | 1 | +----+----------+ 1 row in set (0.00 sec) So, there are few important things here I need to mention! 1) Never delete rows between 1 and 5 doing a gap. 2) If some ip address is not longer available just update the rows with new one or replace it with one from the table. 3) You can insert as many rows as you want but in increment order. Then, join the tables on their proxy_id! SELECT p.proxy_id, p.proxy_ip FROM test.proxy p INNER JOIN test.proxyMap m USING (proxy_id) WHERE m.id = 1 // Result after second update +----------+---------------+ | proxy_id | proxy_ip | +----------+---------------+ | 3 | 123.123.123.3 | +----------+---------------+ 1 row in set (0.00 sec) To run this update statement on schedule you have (at least) 2 options. 1) Use a cron job 2) Use - https://dev.mysql.com/doc/refman/5.1/en/events.html For more information tomorrow
  24. Could you explain and define entire relationships between these entities? Here's your EER Diagram
  25. If you want to use php functions inside sql string, then the syntax should be different. Try, $get_lastweek = mysql_query('SELECT SUM(total) FROM invoices WHERE date_created BETWEEN DATEADD(wk, -1,'. GetDate().') AND '.GetDate());
×
×
  • 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.