Jump to content

macattack

Members
  • Posts

    49
  • Joined

  • Last visited

    Never

Everything posted by macattack

  1. The line that is commented out was uncommented and it returned a 1. So yes, I'm sure the query itself works. It's all the stuff after that that won't work. It won't even return the 1 unless the entire part after (with the exception of the final curly brace) is commented out. If that part is left on, the page is blank.
  2. I have made a few changes to the code, but still no luck. require("mysql.php"); $con = mysql_connect(PATH,USERNAME,PASSWORD); $database = mysql_select_db(DATABASE); if(!$database) { header('Location: login.php?database=no'); } else { $surname1 = strtoupper($_POST['surname']); $name1 = strtoupper($_POST['name']); $surname = mysql_real_escape_string($surname1); $name = mysql_real_escape_string($name1); $query = mysql_query("SELECT * FROM Electors WHERE Surname='".$surname."' AND Name='".$name."';"); //echo mysql_num_rows($query); if(mysql_num_rows($query) >= 2) { echo "Who do you mean?<br/> <table border='1'><tr><th>Name</th><th>Surname</th><th>Address</th><th>Submit</th></tr>"; while($row=mysql_fetch_assoc($query)) { echo "<tr><form action='index.php?task=name&vid=".$row['V_ID']."' method='post'> <td>".$row['Name']."</td><td>".$row['Surname']."</td><td>"; if($row['unit'] != ' ') { echo $row['unit']."-"; } echo $row['number']." ".$row['street']." ".$row['streettype']."</td>"; echo "<td><input type='submit'></td></form></tr>"; } echo "</table>"; } if(mysql_num_rows($query) == 1) { echo "here"; $row = mysql_fetch_assoc($query)); header("Location: index.php?task=name&vid=".$row['V_ID']); } else { header("Location: index.php?task=name&exist=no"); } }
  3. It is returning 1 value (I used a name that I know is in the database once)
  4. I have the following code require("mysql.php"); $con = mysql_connect(PATH,USERNAME,PASSWORD); $database = mysql_select_db(DATABASE); if(!$database) { header('Location: login.php?database=no'); } else { $surname1 = strtoupper($_POST['surname']); $name1 = strtoupper($_POST['name']); $surname = mysql_real_escape_string($surname1); $name = mysql_real_escape_string($name1); $query = mysql_query("SELECT * FROM Electors WHERE Surname='".$surname."' AND Name='".$name."';"); if(mysql_num_rows($query) >= 2) { echo "Who do you mean?<br/> <table border='1'><tr><th>Name</th><th>Surname</th><th>Address</th><th>Submit</th></tr>"; while($row=mysql_fetch_assoc($query)) { echo "<tr><form action='index.php?task=name&vid=".$row['V_ID']."' method='post'> <td>".$row['Name']."</td><td>".$row['Surname']."</td><td>"; if($row['unit'] != ' ') { echo $row['unit']."-"; } echo $row['number']." ".$row['street']." ".$row['streettype']."</td>"; echo "<td><input type='submit'></td></tr>"; } } if(mysql_num_rows($query) == '1') { $row = mysql_fetch_assoc($query)); header("Location: index.php?task=name&vid=".$row['V_ID']); } else { header("Location: index.php?task=name&exist=no"); } } and for some reason, it won't execute past the first if(mysql_num_rows($query)) clause. If someone may know why (I bet it's a minor oversight that an hour or so of trying things hasn't caught) your help is greatly appreciated! Basically, I want to see if the same name is in the list more than once. If it is, the person should have the option to confirm who they are searching for, if it's there once, it should redirect automatically, and if it's not there at all, redirect and give an error message.
  5. The entire output works, with the exception of the V_ID row. The code is pasted below. $sql = "SELECT Electors.V_ID, Electors.Surname, Electors.Name, Electors.Middle, Electors.Phone, Electors.Unit, Electors.Number, Electors.Street, Electors.StreetType, Electors.Postal, Electors.Poll, Calls.V_ID FROM Electors LEFT JOIN Calls ON Electors.V_ID=Calls.V_ID WHERE Electors.Poll=".$_GET['poll']." AND Contact IS NULL AND Voted IS NULL LIMIT 5"; $query = mysql_query($sql); while($row = mysql_fetch_assoc($query)){ echo "<form action='dbupdate.php?task=call&poll=".$_GET['poll']."' method='post'> <input type='hidden' name='ID' value='".$row['V_ID']."'> <tr> <td><input type='hidden' name='surname' value=".$row['Surname']."'>".$row['Surname']."</td> <td><input type='hidden' name='name' value=".$row['Name']."'>".$row['Name']."</td> <td><input type='hidden' name='middle' value=".$row['Middle']."'>".$row['Middle']."</td> <td><input type='hidden' name='phone' value='".$row['Phone']."'>".$row['Phone']."</td> <td><input type='text' length='4' size='6' name='unit' value='".$row['Unit']."'></td> <td><input type='text' length='10' size='7' name='number' value='".$row['Number']."'></td> <td><input type='text' length='30' size='15' name='street' value='".$row['Street']."'></td> <td><input type='text' length='3' size='5' name='streettype' value='".$row['StreetType']."'></td> <td><input type='text' length='7' size='7' name='postal' value='".$row['Postal']."'></td> <td> <select name='call'> <option></option> <option value='1'>Reached</option> <option value='2'>Left Message</option> <option value='3'>No Answer</option> <option value='4'>Wrong Number</option> </select> </td> <td> <select name='support'> <option></option> <option value='pc' "; if($row['Support'] == 'pc'){ echo "selected"; } echo ">PC</option> <option value='lib' "; if($row['Support'] == 'lib'){ echo "selected"; } echo ">Liberal</option> <option value='NDP' "; if($row['Support'] == 'ndp'){ echo "selected"; } echo ">NDP</option> <option value='grn' "; if($row['Support'] == 'grn'){ echo "selected"; } echo ">Green</option> <option value='acc' "; if($row['Support'] == 'acc'){ echo "selected"; } echo ">Accessible/maybe PC</option> <option value='oth' "; if($row['Support'] == 'oth'){ echo "selected"; } echo ">Other</option> </select> </td> <td><input type='text' length='10' size='12' name='partymember' value=".$row['Partymember']."></td> <td><input type='checkbox' name='sign' value='R'></td> <td><input type='checkbox' name='volunteer' value='Y'></td> <td><input type='text' name='email' maxlength='50' value='".$row['Email']."'></td> <td><input type='checkbox' name='donate' value='y'></td> <td><input type='checkbox' name='nocall' value='1'></td> <td><input type='submit'></td> </tr></form>"; } As for the view source, again, same answer. Everything was displaying as it should, with the exception of the V_ID.
  6. Hello, I have mysql query that is returning the first five people that need to be called, $sql = "SELECT Electors.V_ID, Electors.Surname, Electors.Name, Electors.Middle, Electors.Phone, Electors.Unit, Electors.Number, Electors.Street, Electors.StreetType, Electors.Postal, Electors.Poll, Calls.V_ID FROM Electors LEFT JOIN Calls ON Electors.V_ID=Calls.V_ID WHERE Electors.Poll=".$_GET['poll']." AND Contact IS NULL AND Voted IS NULL LIMIT 5"; When I do mysql_fetch_assoc it works for every value except the V_ID value. The values are being printed to a table. It's not showing any errors. If anyone has a solution for this (likely simple) error, please let me know! Also, all values are varchar except V_ID. Thanks in advance!
  7. Thanks. It appears to work now. There are other issues, but not relating to the question at hand.
  8. Ah. There's a command I've never used before. I've done lots of inner joins, but never left/right. I will give that a try. Thanks.
  9. Hello, I'm trying to handle a large CSV file in my mysql. This is my first time dealing with an imported file, and I'm having a few issues. Here's the synopsis of what I'm doing: I receive a file about once per week. This file has ~15,000 names, phone numbers and addresses. During a 30 day period, everyone on the list must be called. I've set up a php file that will take each group from the list and assign it to someone, they do the call and collect the info they need. Here's the problem: I figure the best way to do this is with two tables (I could be mistaken) and the file will be uploaded into one table, the info we collect in the other. They are compared using the ID number in the file. I'm not sure how to begin the process: if someone has not been called yet, they need to be called, and info needs to be collected. When the list is updated, we need to call whoever was not called before. Is there a way to do this with one table, and have the CSV file update the name, phone number and address without affecting the info that we collect? I guess in case this isn't overly clear, if we have already called someone, we don't want to waste time calling them again. It would be appreciated if someone can suggest how I can 1) upload the CSV file without affecting the rest (my thought is the two table solution) and 2) make some kind of query so that only rows where the ID is not on the second list are returned. Once the call is made, a row will be added on the second list with the requisite information and ID number. Thank you in advance for your help.
  10. The excel file has the first, middle and last names. The likelihood of two names matching up is pretty low. It also has addresses, but those are subject to change. The rows are listed in my first post. ID, Phone 1, Volunteer and Sign are all blank.
  11. I have no idea why ID is blank. I don't make the Excel file. It comes from another organization. The ID shouldn't be blank, so I'm guessing the current version is just missing the ID for whatever reason. I can't dump the data on the table for that very reason – without an ID, I can't handle data in a separate table. I have to check the data and import any changes. That's the part that I don't know how to do. If the ID column wasn't blank, it'd be a walk in the park.
  12. I've looked around a bit for some info on this, but I've yet to find anything solid. What I have is an excel file with ~14,000 rows. The columns are as follows: ID, Poll, Last name, first name, middle name, unit, st no, street name, type, community, postal, phone 1, sign, volunteer. ID is blank in every row. On the old version of the file, there is a record under phone number. Every week, I am delivered a new copy of the sheet, with rows inserted randomly. What I need to do is take this file and import the changes into a MySQL database. The MySQL table has a few more rows. I'm wondering what the best way to go about this is. My thoughts are that I export it as a .csv file to start. But how do I import only the changes into the MySQL database? It has to check each row to see if the info is already there (and a 100% match). If the name is there but the address is different, that has to be changed, if no info is there, the entire record has to be added. The important thing is that this gets done without altering any other data in the MySQL table, because other identifying information about each person is in the table, but not in the excel sheets that I get. If someone can give me a hand with this it would be greatly appreciated. I'd prefer to not have to check 14,000 records by hand every week.
  13. That's exactly what I thought. It looks right, but doesn't seem to work. It sounds like everyone received the email though. The first few were unaffected by the bug. Is there a simple way to move past the PHP mail function and implement something else?
  14. No, it's not working. This morning I sent an email. It should have read: To John: "Hello John, --message---" To Jane: "Hello Jane, --message--" To Mary: "Hello Mary, --message--" Instead, every name was listed, with the subject in between each name. ie "Subject Hello John, Subject Hello Jane, Subject Hello Moe, etc. until end of list. --message--" It makes no sense (to me) Any help on why that happened would be great.
  15. Hi, I believe that the error here lies in the PHP and not in the MySQL. I have some code to look through a list of people (but only those with emails) and send an email to them. I tried to do an email this morning, (the mailing list has about 400 people and growing) and it would group names (ie. send "Hello Jane, Hello John, Hello Joe, ... etc. then send it to one person on the list, with the body of the message. Obviously, my intent is to hide names and emails of others on the list, so John would get the email that says "Hello John, --body--" If anyone knows why this is happening, it would be great to find out. I don't want to CC people as it's preferred that identities are secret for privacy reasons. <?php $subject = stripslashes(htmlentities($_POST['subject'])); $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= 'From: [email protected]'; $body = stripslashes(nl2br(htmlentities($_POST['body']))); require("mysql.php"); $con = mysql_connect(PATH,USERNAME,PASSWORD); $db = mysql_select_db(DATABASE); if(!$db){ header("Location: index.php?database=false"); } else { $query = mysql_query("SELECT Name, Email FROM petitioners WHERE Email != '';"); while($row = mysql_fetch_assoc($query)) { $to = $row['Email']; $head = $_POST['head']." ".$row['Name'].","; $body = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 TRANSITIONAL//EN"><html><head><title>'.$subject.'</title></head><body><p>'.$head.'</p><p>'.$body.'</body></html>'; mail($to, $subject, $body, $headers); } header("Location: index.php?email=sent"); } ?>
  16. That was it! It actually solved an older problem with another code that I had left to die too. It's weird that such a simple mistake slipped by. Must be something to do with the fact that it's the morning after Christmas. Thank you for your help.
  17. I am building a simple login script that will work with a MySQL database to allow administrator access to the site. For some reason the script stops executing immediately after the title. As I am currently still working on the site, error_reporting() is set to e_all and no errors come up. Here is the code: <?php include ("header.php"); ?> <h2 class='center'>Administrator Login</h2><br/> <h3> <form action="admin_login.php?login='yes' method='POST'> Username: <input type='text' name='login'><br/> Password: <input type='password' name='pass'><br/> <input type='submit' value='Login'><br/> </form> </h3> <?php include ("footer.php"); ?> Everything up until the <form> tags comes up just fine. After that, the page is blank. The form does not display either. This same template is used on every single page and works just fine everywhere else. If anyone has an idea that may lead to a solution that would be great. Thanks in advance!
  18. Ah that was easy. Thanks!
  19. Hello, I am making a remarkably simple error that I cannot detect in the following code: print ("<h6>Copyright &copy 2008"); if (!date("Y") == '2008'){ echo "-".date("Y"); echo "test"; } print (" <a href='mailto:[email protected]'>My Name</a>, all rights reserved."); I'm trying to have it automatically display 2008-present automatically, and I added the "test" portion to see if the if statement is being properly executed — it isn't. If someone knows what I did wrong and could help me, that would be great. Thanks in advance
  20. Thanks! That was the trick I was missing. I've never had something with this complexity before, so it was confusing.
  21. Hello, I'm currently designing a website (my first complex one with CSS), and I have a navbar that displays at the top of every page. I want this navbar to be one colour, and the rest of the page another. I set a class of the <body> tag to "navbar", and set it to a blue colour, and the default body tag to white, however, the whole page renders with the blue colour. Here is the offending stylesheet snippet: body {background-color: white; } body.navbar {background-color: #041374; } and here is the offending implementation (the navbar is "topbar.php"): print "<body class='navbar'>"; include "topbar.php"; print "<body class='none'>"; and here is the navbar: <?php print ("<img class='header' src='images/de18.jpg'> <h1>Welcome to the Silver Fox Curling & Yacht Club</h1> <h3> <a class='header' href='events.php'>Events</a> <a class='header' href='entertainment.php'>Entertainment</a> <a class='header' href='curling.php'>Curling</a> <a class='header' href='sailing.php'>Sailing</a> <a class='header' href='contact.php'>Contact Us</a> <a class='header' href='management.php'>Management</a> <a class='header' href='virtual.php'>Virtual Tour</a> </h2><br/> "); ?> The only part that doesn't work is the change back to a white background. If you could direct me in the right direction, that would be wonderful. Thank you in advance!
  22. Hi, I've looked through some of the archives in regard to umask, and I still have some very important security questions that I'm hoping someone can advise me on. My host has a default umask(022) set, which causes problems for me in regard to file deleting and editing. Even if I use FileZilla to change the permissions, they remain as 644. I am wondering what the most secure approach is — I currently don't have a user log in to access the file creation part of the site, it's currently just a directory that I've told a few friends about, my next project is to require users to log in. My host suggests setting umask(000), and then set the file permissions to 666 in mkdir(), but I'm wondering if that opens a "Pandora's box". If someone can suggest a secure approach (other than the logical "require users to log in", that's coming soon), that would be great. I want full control to read and write, and I want my PHP code to be able to do that work automatically. As it stands, even if I attempt to change the permissions in FileZilla, it doesn't let me do it, and I can't delete the file. Any help would be appreciated.
  23. Thanks for the suggestion. I had tried that, but it didn't seem to do anything. I believe I had commented out fairly big blocks. I will make another, more specific, attempt when I have time again.
  24. Thanks, I made the change in regard to the missing apostrophe in the link. However, that made no difference in the link that was being output. Even when I changed the $filename variable to anything else, the name being output didn't change! I cleared my cache and history, restarted my computer, and tried with Safari 3.1.1, Firefox 3 RC2 and IE 5 for Mac, and all three displayed the same result. No form, wrong link and br tags that weren't in the code. As for your suggestion with the form tags, they must remain where they are, as it is returning a list from an array, with each blog post requiring its own edit or delete option. I know that the code should work, I just need some help figuring out why it's generating the wrong link. Here's the entire function, I'm wondering if the issue lies somewhere else? function displayBlogsButtons($dir = '../blogs'){ foreach(scandir($dir) as $entry) if($entry != '.' && $entry != '..' && $entry != '.svc') { $entry = $dir.'/'.$entry; if(is_dir($entry)) { $path = pathinfo($entry); $listarray[$path['blogs']] = listblogs($entry); } else { $path = pathinfo($entry); $filename = $path['filename']; $linkAddress = "index.php?edit=List&view=true&blog=$entry"; $listarray[] = $path['blogs']; print ("<tr><td> <a href='$linkAddress'>$filename</a> </td><td> <form action='index.php' method='post'> <input type='hidden' name='blog' value='$entry'> <input type='hidden' name='title' value='$filename'> <input type='submit' name='edit' value='Edit'> <input type='submit' name='delete' value='Delete'> </form> </td></tr>"); } } } It's a function that will check the directories, starting at the level YYYY then moving on to MM then DD. It should then print the specified link for each post found inside the DD directory. The posts are being returned correctly, as I've noted, but the link isn't being generated properly and the form won't appear.
×
×
  • 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.