Jump to content

grandadevans

Members
  • Posts

    30
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

grandadevans's Achievements

Member

Member (2/5)

0

Reputation

  1. No, I had the whitespace problem only last week, but I know what to look for when I get that 'header already sent error' and I've changed nothing since then.
  2. Got IT! I changed it from [code] <?php require_once('Connections/campaign.php'); ?> <?php $company=$_POST['id']; mysql_select_db($database_campaign, $campaign); $query_companies = "SELECT DISTINCT entryID, company, companyEmail, URL FROM BFPO_unfriendly WHERE company IS NOT NULL"; $companies = mysql_query($query_companies, $campaign) or die(mysql_error()); $row_companies = mysql_fetch_assoc($companies); $totalRows_companies = mysql_num_rows($companies); $query_companyDetails=sprintf("SELECT entryID, company FROM BFPO_unfriendly WHERE companyEmail LIKE '$company';"); $companyDetails=mysql_query($query_companyDetails, $campaign) or die (mysql_error()); $row_companyDetails=mysql_fetch_assoc($companyDetails); ?><?php if ($_POST['Submit']) { require("phpmailer/class.phpmailer.php"); $companyID=$row_companyDetails['entryID']; $IP=$_SERVER['REMOTE_ADDR']; $email=$_POST['email']; $name=$_POST['name']; $message=$_POST['description']; $subject=$_POST['subject']; if ($_POST['id'] !== 'all') { //Start of email to individual companies if (isset($email)){ $insert ="INSERT INTO emails_sent (companyID, name, email, message, IP) VALUES ('$companyID', '$name', '$email', '$message', INET_ATON('$IP'));"; mysql_query($insert) or die(mysql_error()); $loc='forms2.php?sent=' . $row_companyDetails['company']; header("location: $loc"); [/code] to [code]<?php require_once('Connections/campaign.php'); $company=$_POST['id']; mysql_select_db($database_campaign, $campaign); $query_companies = "SELECT DISTINCT entryID, company, companyEmail, URL FROM BFPO_unfriendly WHERE company IS NOT NULL"; $companies = mysql_query($query_companies, $campaign) or die(mysql_error()); $row_companies = mysql_fetch_assoc($companies); $totalRows_companies = mysql_num_rows($companies); $query_companyDetails=sprintf("SELECT entryID, company FROM BFPO_unfriendly WHERE companyEmail LIKE '$company';"); $companyDetails=mysql_query($query_companyDetails, $campaign) or die (mysql_error()); $row_companyDetails=mysql_fetch_assoc($companyDetails); if ($_POST['Submit']) { require("phpmailer/class.phpmailer.php"); $companyID=$row_companyDetails['entryID']; $IP=$_SERVER['REMOTE_ADDR']; $email=$_POST['email']; $name=$_POST['name']; $message=$_POST['description']; $subject=$_POST['subject']; if ($_POST['id'] !== 'all') { //Start of email to individual companies if (isset($email)){ $insert ="INSERT INTO emails_sent (companyID, name, email, message, IP) VALUES ('$companyID', '$name', '$email', '$message', INET_ATON('$IP'));"; mysql_query($insert) or die(mysql_error()); $loc='forms2.php?sent=' . $row_companyDetails['company']; header("location: $loc"); [/code] And now it works, I've undone and redone it a few times to make sure and the problem is solved. looking at it, it may have been the indent before the [code] <?php require_once('Connections/campaign.php'); ?>[/code] but then surely it would have come up with an error saying that the header was already sent
  3. That echoes the right URL [code]forms2.php?sent=Argos[/code] but it just echoes it, it still skips the header. I've tried a few things. I put a header at the head of the page and it worked fine. I've moved the script as far up the page as possible and it still does not work, the only code infornt of it is [code]<?php require_once('Connections/campaign.php'); $company=$_POST['id']; mysql_select_db($database_campaign, $campaign); $query_companies = "SELECT DISTINCT entryID, company, companyEmail, URL FROM BFPO_unfriendly WHERE company IS NOT NULL"; $companies = mysql_query($query_companies, $campaign) or die(mysql_error()); $row_companies = mysql_fetch_assoc($companies); $query_companyDetails=sprintf("SELECT entryID, company FROM BFPO_unfriendly WHERE companyEmail LIKE '$company';"); $companyDetails=mysql_query($query_companyDetails, $campaign) or die (mysql_error()); $row_companyDetails=mysql_fetch_assoc($companyDetails); if ($_POST['Submit']) { require("phpmailer/class.phpmailer.php"); $companyID=$row_companyDetails['entryID']; $IP=$_SERVER['REMOTE_ADDR']; $email=$_POST['email']; $name=$_POST['name']; $message=$_POST['description']; $subject=$_POST['subject']; if ($_POST['id'] !== 'all') { [/code] This one has got me totally flustered
  4. The [code]if ($_POST['submit']){ [/code] didn't work as it didn't insert anything in the database. I changed it to [code]if (isset($_POST['email'])){ [/code] which is a required field and that inserted the record into the db but skipped the header. It obviously recognises the $loc as when the page refreshes it echoes the $loc as requested. Here is the code that I have just used. [code]if (isset($_POST['email'])){ $insert ="INSERT INTO emails_sent (companyID, name, email, message, IP) VALUES ('$companyID', '$name', '$email', '$message', INET_ATON('$IP'));"; mysql_query($insert) or die(mysql_error()); $loc='forms2.php?sent=' . $row_companyDetails['company']; header("location: $loc"); } echo $loc; [/code]
  5. That work's fine. I have several headers on my site already and have never had a problem that I've not been able to work through by myself before but this one is getting the best of me.
  6. I've just tried [code] <?php $loc='forms2.php?sent=' . $row_companyDetails['company']; if (isset($loc)) { header("Location: test.php"); ?> [/code] and [code]<?php if (isset($insert)) { header("Location: forms2.php?sent=' . $row_companyDetails['company']"); } ?>[/code] For the second one I get a Parse error Remember that I'm only uising test.php to see if it is definitively failing.
  7. Nope, Still not working This is the actual code that I am using, I was just using test.php as an example to see if it would go to the URL as it would have been a 404 error and easier to spot than looking at the address bar. [code] $insert ="INSERT INTO emails_sent (companyID, name, email, message, IP) VALUES ('$companyID', '$name', '$email', '$message', INET_ATON('$IP'));"; mysql_query($insert) or die(mysql_error()); $loc='forms2.php?sent=' . $row_companyDetails['company']; if (isset($loc)) { header("Location: $loc"); } echo $loc; [/code]
  8. Hi all, Can anybody help me, I have a script, here are the relevant lines [code] mysql_query($insert) or die(mysql_error()); $loc='test.php; header("Location: $loc"); echo "test"; [/code] The problem is that it looks like it is just skipping the header line. After the form has been completed, it completes the MySQL query, just refreshes the same page and echoes the "test" line. There is no error message or anything, it just skips the line, I have tried it this way and with a direct reference to a page ie [code]header("Location: test.php") [/code] but that doesn't work either! Anybody got any ideas?
  9. Cheers mate, I've also implemented the suggestion about storing IP addresses. John
  10. I tried several combinations of that but couln't do it with getting a 1,2,3,4,5 etc no matter how I ordered the subquery John
  11. GOT IT! The books have come in handy for once. The solution I have is to create a couple of temporary tables then use them like so [code] SET @posLastWeek :=0; SET @posThisWeek :=0; DROP TABLE IF EXISTS lastWeek; DROP TABLE IF EXISTS thisWeek; CREATE TEMPORARY TABLE lastWeek SELECT @posLastWeek :=@posLastWeek+1 AS pos, c.companyID, COUNT(c.clickID) AS clicksLW     FROM click_log c WHERE WEEK(c.`date`)=WEEK(CURDATE())-1 AND companyID !=0     GROUP BY c.companyID ORDER BY clicksLW DESC LIMIT 10; CREATE TEMPORARY TABLE thisWeek SELECT @posThisWeek :=@posThisWeek+1 AS pos, c.companyID, COUNT(c.clickID) AS clicksTW     FROM click_log c WHERE WEEK(c.`date`)=WEEK(CURDATE()) AND companyID !=0     GROUP BY c.companyID ORDER BY clicksTW DESC LIMIT 20; SELECT * FROM lastWeek; SELECT * FROM thisWeek; SELECT t.pos, b.company, t.clicksTW, l.pos, l.clicksLW     FROM thisWeek t         LEFT JOIN lastWeek l USING (companyID)         LEFT JOIN bfpomerchants b USING (companyID)     ORDER BY t.pos ASC; DROP TABLE lastWeek; DROP TABLE thisWeek;[/code] Resulting in [code] +------+--------------------------------+----------+------+----------+ | pos  | company                        | clicksTW | pos  | clicksLW | +------+--------------------------------+----------+------+----------+ |    1 | Let's Go Retro                 |       12 | NULL |     NULL | |    2 | Surplus and Adventure Ltd.     |       11 |    1 |       64 | |    3 | Amazon                         |       11 |   10 |        9 | |    4 | Woolworths                     |        9 | NULL |     NULL | |    5 | Sports Warehouse               |        6 | NULL |     NULL | |    6 | Primrose Aromatherapy          |        6 | NULL |     NULL | |    7 | Sportsshoes Unlimited          |        5 | NULL |     NULL | |    8 | Mean and Green                 |        5 | NULL |     NULL | |    9 | Marks and Spencers             |        4 | NULL |     NULL | |   10 | Island-Leisure                 |        4 | NULL |     NULL | |   11 | Teddy Love                     |        4 | NULL |     NULL | |   12 | Spritz                         |        4 | NULL |     NULL | |   13 | Gadget Pages Ltd               |        3 | NULL |     NULL | |   14 | Bookplace Ltd                  |        3 | NULL |     NULL | |   15 | Penrith Survival Equipment Ltd |        3 | NULL |     NULL | |   16 | BrightMinds                    |        3 | NULL |     NULL | |   17 | Moonpig                        |        3 |    5 |       17 | |   18 | Physio Supplies                |        3 | NULL |     NULL | |   19 | Clean Store                    |        3 | NULL |     NULL | |   20 | Cadbury Gifts Direct           |        2 | NULL |     NULL | +------+--------------------------------+----------+------+----------+[/code] Cheers Fanway. If anybody has any easier ways to do it feel free to let me know. John
  12. Hello everybody yet again, I have a table which logs A) The users IP address B) The company ID of the company clicked The table looks like this [code] +-----------+--------------+------+-----+-------------------+----------------+ | Field     | Type         | Null | Key | Default           | Extra          | +-----------+--------------+------+-----+-------------------+----------------+ | clickID   | int(11)      | NO   | PRI | NULL              | auto_increment | | date      | timestamp    | YES  | MUL | CURRENT_TIMESTAMP |                | | companyID | int(11)      | YES  | MUL | NULL              |                | | URL       | varchar(255) | YES  |     | NULL              |                | | referer   | varchar(50)  | YES  | MUL | NULL              |                | | IPAddress | varchar(100) | YES  |     | NULL              |                | | agent     | varchar(255) | NO   | MUL |                   |                | +-----------+--------------+------+-----+-------------------+----------------+[/code] How do I select instances of the same IP address with the same compay ID for example, what I want to do is DELETE rows where the same IP address and companyID combination appear more than 4 times. Can anybody help me out? Thanks John
  13. Nice One, Cheers mate, that works a treat but now I've run into another problem. The statement I have currently looks like this [code] SELECT b.company, b.companyID, @posThisWeek :=@posThisWeek+1 AS posThisWeek,   (SELECT COUNT(c.clickID) FROM click_log c   WHERE c.companyID=b.companyID AND WEEK(c.`date`)=WEEK(CURDATE())-1   GROUP BY c.companyID LIMIT 1) AS clicksLastWeek,   (SELECT COUNT(c.clickID) FROM click_log c   WHERE c.companyID=b.companyID AND WEEK(c.`date`)=WEEK(CURDATE())   GROUP BY c.companyID LIMIT 1) AS clicksThisWeek FROM bfpomerchants b ORDER BY clicksThisWeek DESC LIMIT 10;[/code] This gives me the top 10 with number of clicks per company for the last 2 full weeks. My problem is that I can't figure out how to get the position of 'clicksLastWeek' as every time I try the @ statement it show the record number (obviously, and that is what I asked for!) It works fine for this weeks position but do you know how I could get the position of the week before, Ive tried it in subqueries but can't do it with only 1 column. Any ideas. Thanks again John
  14. Hi, thanks for your help When I tried the code [code]SET @rowNumber := 0; SELECT @rowNumber=rowNumber+1 AS rowNumber, a.otherNumber FROM a ORDER BY a.otherNumber ASC[/code] It came up with something like 'unknown colum rowNumber' I tried all sorts of variations including [code]SELECT @rowNumber=@rowNumber+1;[/code] But that just keeps coming up with '0' as the answer. Do you have any idea why or what I can do I have tried setting the @rowNumber in a subquery but it won't let me. John
×
×
  • 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.