Jump to content

Psycho

Moderators
  • Posts

    12,157
  • Joined

  • Last visited

  • Days Won

    129

Everything posted by Psycho

  1. So why are you asking? Unless your code has to follow a particular format for business reasons, go with whatever logical format works for you. According to the zend framework standards, which some subscribe to, functions and classes have the brackets on thier own line, but loops and other constructs include them in-line with other code. Personally I prefer to use the more verbose method (your first example) as it makes readability easier - at least for me - especially when going back to code I've written months/years earlier.
  2. The easiest solution would to provide a link in the email to the newsletter rather than the newsletter itself. Many email clients will suppress images by default anyway beacuse spammers would use images in email to track valid email addresses. Although, depending on the "format" of the newsletter it might be possible to include a link that get's activated when the document is opened. But, this again could be seen as a security issue on the user's part.
  3. You are apparently using a database extraction class: $result = $connector->query("SELECT * FROM accessnumbers where state='$state' AND npa='$npa' ORDER BY city ASC"); $numres = $connector->fetchRow($result); By the basis of the "$connector->" statements. So, I don't think you can use the regular mysql_fetch_array() statement in the results page. I *think* you should be using the fetchRow() method of the class. But, as I don't know what the class is I can't say for sure.
  4. I wqas referring to the enctype, which you have set. I dont think this has anything to do with your problem, but is there any reason why you do not put any of yout HTML tag parameter values in quotes? That's really bad form. In this line: <input type=submit value=Upload File /> The value of that field is NOT interpreted as "Upload File". It will simply be passed as "Upload". Looking at the actual FORM fields I don't see any that would be affected by this type of problem. BUt, it would be best to have properly formatted HTML to begin with. Plus, you are using short tags (i.e. <? ) which are not always supported and are discouraged. Also, I don't even see HTML opening and closing tags. Again, I don't think this has anything to do with your problem, just things I would expect on a properly created page. Here is a modified version of your page that corrects those errors and is more efficient <?php session_start(); if (!isset($_SESSION[user])) { header ('Location: index.php'); exit; } else { $dateOptions = ""; for($day=1; $day<=31; $day++) { $dateOptions .= "<option value=\"{$day}\">{$day}</option>\n"; } $monthOptions = ""; for($monNum=1; $monNum<=12; $monNum++) { $mon = date("F", mktime(0, 0, 0, $monNum+1, 0, 0, 0)); $monthOptions .= "<option value=\"{$mon}\">{$mon}</option>\n"; } } ?> <html> <body> <h2>Upload a Newsletter</h2> <form enctype="multipart/form-data" action="upload_news.php" method="POST"> <input type="hidden" name="MAX_FILE_SIZE" value="2097152" /> Choose a file to upload: <input name="uploadedfile" type="file" /><br /> Select the corresponding month: <select name="month"> <?php echo $monthOptions; ?> </select><br> Please select a day: <select name="day"> <?php echo $dateOptions; ?> </select> <br> <input type="submit" value="Upload File" /> </form> </body> </html>
  5. Just as an aside, do you realize you have an unhandled error in that logic? If the first query succeeds and the second does not, there is no response given. If you decide that you will continue with the current process of deleting records from each table individually, I would suggest reversing the process. Delete the associated records and then the parent record. Otherwise, if there is a problem, you would have orphaned records. Example: if ($_GET['action'] == 'delete') { $id = mysql_real_escape_string($_GET['id']); $deleteProgress = mysql_query("DELETE FROM progress WHERE userid = '".$id."'") or die(mysql_error()); if ($deleteProgress) { $deleteUser = mysql_query("DELETE FROM users WHERE id = '".$id."'") or die(mysql_error()); } if ($deleteProgress && $deleteUser) { $status = "Successfully deleted the selected user."; } else { $status = "Failed to delete the selected user!"; } }
  6. What encoding are you using on your form for the file upload? Post the form.
  7. The spirits say . . . "how the hell should we know?!" Seriously though, it would take you how long to actually try it as opposed to posting on here to ask us if it will work? If the solution to your problem was patently obvious to us we would have said "change 'x' to 'y' to fix the problem". But, your problem is not an obvious one. You will need to use critcal thinking skills to identify the root cause. Once you have that, then you can find a solution. You will need to come up with specific tests that will rule out opne thing vs. another. Hopefully someone will have had a similar issue will be able to piont you in a specific direction. But, as of right now I *think* we have rules out the PHP code as being the issue since you can't even upload a PDF file via FTP and have it work correctly. If I were you I would try the other transfer mode. If that doesn't work contanct your host provider as it seems like a problem on the server. On a side note, have you verified that you are not over your storage limit?
  8. I wouldn't use array_multisort() for this because you would have to first "transform" the array into a different format (see Example#3). A better option, in my opinion, would be to use usort() to define your own sorting function. function sortByName($a, $b) { return strcasecmp($a['cust_name'], $b['cust_name']); } usort($data, "sortByName"); //Records will now be sorted based on name You can also get fancier to sort by two or more columns, i.e. the the primary value is equal then do a secondary (or more) sort on another column. function sortByNameIP($a, $b) { if (strcasecmp($a['cust_name'], $b['cust_name'])==0) { //If name is same, then sort on ip return strcasecmp($a['cust_ip'], $b['cust_ip']); } return strcasecmp($a['cust_name'], $b['cust_name']); } usort($data, "sortByNameIP"); //Records will now be sorted based on name, then IP Note: I have not tested any of this. It may work as expected, not sure. It's late and I'm not in the mood for creating test data. But the idea is sound.
  9. <img src="image.jpg" style="width:15%;height:15%" onmouseover="this.style.width='100%';this.style.height='100%'" onmouseout="this.style.width='15%';this.style.height='15%'" >
  10. Well, there's your problem. You modified my code perfectly and didn't take into account that I make mistakes (note disclaimer in my sig) This line oneChecked = false; Should be (notice the 'n') noneChecked = false;
  11. Learn how to use JOINS to really utilize a database SELECT t.moj_id, t.track_artist, t.track_title, m.moj_title FROM tracks t JOIN mojocd m ON t.moj_id = m.moj_id WHERE upper(t.track_artist) LIKE '%$find%' OR upper(t.track_title) LIKE '%$find%'
  12. Where's your code (or post a link)? It should look something like this if you followed my code as an example: var noneChecked = true; var checkboxLen = form1['item[]'].length; for (var i=0; i<checkboxLen; i++) { if (form1['item[]'].checked) { oneChecked = false; break; } } if (noneChecked) { alert('Nothing checked.'); return false; }
  13. Yes, but to be honest, after doing a little more digging the whole "PTC" thing seems a little shady to me. All I found were numerous forum posts of immature arguments over which PTC script was the best and which ones have been "nulled", etc. Plus, there were numerous references to torrents and warez. I'm not comfortable in helping you to do something that may not be above board.
  14. Exactly! You should (in my opinion) develop your site without any javascript to have a functioning site. Then add "unobstrusive" javascript where appropriate to enhance the user experience. Here's an example to illustrate. Let's say you need the user to enter their state and city from predefined lists. You have a list of states and lists of cities for each state. You wouldn't want the user to enter a city and state combination that doesn't exist. For the "non-javascript" implementation you could have the state and city lists populated with all possible values and do the validation server-side. If the user selects a combination that is not valid redisplay the form for them to make another selection. It works, but is not exactly user friendly. So, you decide to implement some javascript on top of the non-js implementation. You could use strait JS or AJAX to dynamically populate the city list as the user changes the selected state so the user can't make an invalid selection. However, you would still keep the server-side validation in case the user has JS turned off. The "unobtrusive" part would come into play on page load. By default you would populate all values in the lists to accomodate the non JS users. But youwould implement an onload function to automatically repopulate the city list based upon the default state.
  15. You paid for that? Well, then, use it if you wish. I also think that code is less than optimal based upon the fact that one page load can cause multiple emails if multiple values have the disallowed characters. I would consider one request with multiple questionable values as a single "hack" attempt. Well, the results you received show that there is a key in either POST, GET or COOKIE of the name '__utmz' with a value of: 265474251.1249069436.1.1.utmccn=(direct)|utmcsr=(direct)|utmcmd=(none) You will have to determine if you need/want that value and take appropriate action. Either take out the code that creates that value, modify it to not use the | character, remove the "hack" validation script, etc. etc. EDIT: A quick google search seems to indicate that value is a cookie and is related to Google Analytics.
  16. Where did you get that code? Seems more complicated than it needs to be. Specifically this line: while(list($keyx,$valuex) = each($_REQUEST)){ I think it could be simplified as foreach ($_REQUEST as $keyx => $valuex) In any event, I don't see anything 'logically' wrong with the test being done. But, the REQUEST variable contains all data in POST, GET and COOKIE. If there is anything in only one of those variables that does contains one of the disallowed characters you will receive an email. Personally, that is a stupid test in my opinion. Did you tell the user they can't use those characters? Even so, why should you care if someone does use those characters? Your code should properly handle those characters using mysql_real_escape_string() function. So, there is no reason to disallow those characters or even do a "hack" check. But, if you really want to know why you are getting the emails, just add additional information to the email to identify the variable and value where the error is being triggered. while(list($keyx,$valuex) = each($_REQUEST)){ if(eregi("([*])|([|])|([;])",$valuex)){ $msg = "There's been a SQL Injection hacking attempt. $HTTP_REFERRER $REMOTE_ADDR\n\n"; $msg .= "Key: $keyx\n Value: $valuex"; mail($set['contact_email'],"Hack Alert", $msg,"FROM:".$ir['email']); echo "test"; } } However the REQUEST variable won't be able to tell you where that key/value is coming from (i.e. POST, GET, COOKIE).
  17. Good deal. However, on retrospect, even if you went with my solution you might need to incorporate Nightslyr's process as well if you need to add IDs to the elements. You can have elements with the same name, but you can't have elements with the same IDs. So, if you need IDs you would have to ensure they are unique.
  18. First off, when posting to the JavaScript forum, post the "rendered" javascript code, do not post the PHP that creates teh code as it makes it difficult to debug. The exception is is there is a problem with the PHP process of generating the JavaScript. Without seeing the checkbox fields themselves (as dpacmittal stated) it's kind of hard to provide a solution. But, I woud suggest that you make the checkbox fields an array to make this easier. Exmaple checkboxes Option 1: <input type="checkbox" name="options[]" value="1" /> Option 2: <input type="checkbox" name="options[]" value="2" /> Option 3: <input type="checkbox" name="options[]" value="3" /> Then, in your javascript use something like this: var noneChecked = true; var checkboxLen = form1['options[]'].length; for (var i=0; i<checkboxLen; i++) { if (form1['options[]'][i].checked) { oneChecked = false; break; } } if (noneChecked) { alert('Nothing checked.'); return false; }
  19. Or, alternatively, an easier solution is to just make the name of that field an array name. So, you can add as many rows as you like with the same name and the values will be POSTed as an array. Just add square brackets. Ex: name="fieldName[]" Then the processing page can access the values from all of those fields using: $_POST['fieldName'] $_POST['fieldName'][0] = value from 1st field $_POST['fieldName'][1] = value from 2nd field $_POST['fieldName'][2] = value from 3rd field etc...
  20. You need to extract the video from the DVD. A DVD video will typically contain different versions of the subtitles that the user can choose and they are separate from the video itself. But, in order to convert video to a format that does not support subtitles (i.e. youtube) the subtitles must be made part of the video itself and cannot be removed at that point. Think of the subtitles in a DVD like the signs in front of a fast food restaurant where the establishment can affix different letters on their sign to hawk the deal of the day. Then, when converting to a format that does not support subtitles the analogy would be someone painting the actual letters on their sign. You need to get the DVD of the movie and extract the video you want to work with. Then use a video authoring application to add your own subtitles. Then convert to whatever format you want.
  21. Your last statement before bumping was Did you try that?
  22. Well, I mocked something together using the code you have above, and it works for me. But, I commented out the first two lines of javascript as it had nothing to do with finding the width of the div. I suspect that is where the problem lies. This line will generate an error: document.getElementById('ads') = '<p>' + alternateCode+ '</p>'; That line is setting the "object" to a string value. I think you mean to do this: document.getElementById('ads').innerHTML = '<p>' + alternateCode+ '</p>'; If there are errors please post them, we can only help based upon the information provided
  23. You're making it too complicated: <?php $xbox = array(1,2,3,4,5); //this will be take from database - this is just for testing reset($xbox); if($_POST['box']){ //Saved the submitted values to session variable $_SESSION['storedbox'] = $_POST['box']; foreach($_SESSION['storedbox'] as $key => $value){ echo "The value of \$_SESSION['{$key}'] is {$value}<br />\n"; //just for testing } } //Create the form echo "<form action=\"\" method=\"POST\">\n"; foreach($xbox as $x){ if (isset($_SESSION['storedbox']) && is_array($_SESSION['storedbox'])) { //Set the checked state for each option $checked = (in_array($x, $_SESSION['storedbox'])) ? ' checked="checked"' :''; } //Display label and checkbox echo "box_{$x}<input type=\"checkbox\" name=\"box[]\" value=\"{$x}\"{$checked} /><br />\n"; } echo "<button type=\"submit\"> go </button></form>"; ?>
  24. Ah, yes. I lost focus when reading through the posts. I tried offsetWidth in both IE and FF and it worked. But, in some code snippets I have there was also use of clientWidth. I had assumed that both were needed for compatability issues, but I typically only test in IE & FF initially. So maybe something like this would work better: var divObj = document.getElementById(divId); var divWidth = divObj.offsetWidth || divObj.clidsadentWidth;
×
×
  • 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.