Jump to content

Psycho

Moderators
  • Posts

    12,159
  • Joined

  • Last visited

  • Days Won

    130

Everything posted by Psycho

  1. Does the swear word get displayed on the page in the first example from this line? echo $word . "<br/>"; If not, are you sure the query returns any results and/or that the results have a column named 'word'? In any event, the process above is not very efficinet and, worse, will make improper replacements. For example, this "shitzu dogs" would become this "***zu dogs". You need to use preg_replace(). Add all the bad words to an array as a regular expression using the word boundry metacharacter to find whole words, along with the case insensitive switch. This will ensure that only whole word matches are replaced. <?php include('../../includes/inc.conn.php'); function swear_filter($string) { $words = array(); $query = "SELECT word FROM bad_words"; $result = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_array($result)){ $words[] = '/\b' . $row['word'] . '\b/i'; } return preg_replace($words, '***', $string); } $string_to_check = "My shitzu took a Shit on the carpet."; echo swear_filter($string_to_check); //Assuming the word 'shit' is in the db results //Output: "My shitzu took a *** on the carpet" ?>
  2. Yeah, I'm sure they won't mind you doing that.
  3. Assuming the select lists go from 12:00am to 11:45pm with 15 minute increments, this will do the job. I only included a few hours worth of times for demonstration purposes. If the increments are NOT in 15 minutes, then you need to change the '4' in the function calculation accordingly (30 minutes would be 2, 10 minutes would be 6, etc). <html> <head> <script type="text/javascript"> function updateEnd(beginIdx) { endSelectObj = document.getElementById('end'); endSelectObj.selectedIndex = (beginIdx+4) % endSelectObj.options.length; } </script> </head> <body> Start: <select name="start" id="start" onchange="updateEnd(this.selectedIndex);"> <option value="8:00">8:00</option> <option value="8:15">8:15</option> <option value="8:30">8:30</option> <option value="8:45">8:45</option> <option value="9:00">9:00</option> <option value="9:15">9:15</option> <option value="9:30">9:30</option> <option value="9:45">9:45</option> <option value="10:00">10:00</option> <option value="10:15">10:15</option> <option value="10:30">10:30</option> <option value="10:45">10:45</option> </select> <br> End: <select name="end" id="end"> <option value="8:00">8:00</option> <option value="8:15">8:15</option> <option value="8:30">8:30</option> <option value="8:45">8:45</option> <option value="9:00">9:00</option> <option value="9:15">9:15</option> <option value="9:30">9:30</option> <option value="9:45">9:45</option> <option value="10:00">10:00</option> <option value="10:15">10:15</option> <option value="10:30">10:30</option> <option value="10:45">10:45</option> </select> </body> </html>
  4. Did you say "please"? I notice the code doesn't handle upper-case characters - it transforms them all to lower-case when it "flips" them. I guess there isn't upside down equivalents for them all. Plus, some lower case letters aren't made upside down (at least the z isn't) Interesting feature, but I'm not sure I see a practical implementation.
  5. $query = "SELECT p.*, COUNT(c.replyto) as comment_count FROM posts p LEFT JOIN comments c ON p.id = c.replyto WHERE p.school={$school_id} GROUP BY c.replyto LIMIT 0 , 15"; http://dev.mysql.com/doc/refman/5.0/en/select.html
  6. How foolish of me to assume you were talking about a file. Well, then, you could do the same thing as file() by exploding the value on the new line character. I still think processing the file line-by-line appears to be the most efficient. But, not knowing exactly how you are going to use the data, there might be a better method.
  7. I'm having a problem understanding your variables? Whar variable represents the quantity? Also, what is the difference between $shipping[0] and $shipping[1] This should be a simple problem (I'll use $quantity to represent the quantity) if ($quantity <= 4) { $shipping[0] = 4.95 } elseif ($quantity <= 15) { $shipping[0] = 10.35 } elseif ($quantity <= 30) { $shipping[0] = 13.95 } else { //Contact seller } Edit, your original post states the seller want to "add" those costs for the larger quantities. If that means that 5-15 units will be (4.95 + 10.35) and 16-30 units will be (4.95 + 10.35 + 13.95), then just change the $shipping[0] = xxx; to shipping[0] += xxx; on the additional quantities lines
  8. I would use file() to read the file into an array with each line a different element of the array. You can then iterate through the array and pick out different pieces of data as needed. You would have the start and end lines as elements, but you could use those when processing the array to differentiate between different records.
  9. Need to see the layout of your tables to really provide the proper query. But, your query would look something like this: SELECT posts.*, COUNT(comments.replyto) as comment_count FROM posts LEFT JOIN comments ON posts.id = comments.replyto GROUP BY replyto This would pull a list of all posts records and their data along with another field value for the comment count.
  10. A switch is only useful when you have a single parameter as the switch. I have a feeling there's a more logical way to approach your problem, but I can't see what you are actually doing. The first three conditions all have the same result. So there is no reason you have to separate them. This should accomplish the same thing //If that was a limitless train, and that was the last possible row, end the table. //OR If that was a limited train, and that was the last possible row, end the table. if ( (($i == 7) && ($j == && ($containsLimit != FALSE)) || (!$containsLimit && $k==$thisLimit) || ($containsLimit && $k==$rowsLeft) ) { echo '</tr></table><br /><br /><br />'; $i = 1; $j = 1; $k = 1; } //If that was the sixth column, and not the eighth row, end the row, and start a new one. elseif (($i == 7) && ($j != ) { echo '</tr><tr>'; $i = 1; $j++; $k++; } else { $i++; $k++; }
  11. I suck at regular expressions, so I'm sure this is not the most efficient, but it beats the hell out of splitting the text into an array: $row_ot['product_name']="sony ericsson w995 black"; $pn = preg_replace('/([^ ]*?)( )([^ ]*?)( )/', "\1 \3,", $row_ot['product_name']); echo $pn; //Output: "sony ericsson,w995 black" This works no matter how many words are in the string. Although it wouldn't handle consecutive spaces well. Edit (improved version): $row_ot['product_name']=" sony ericsson w995 black"; $pn = preg_replace('/([^ ]+?)( +)([^ ]+?)( +)/', "\\1\\2\\3, ", $row_ot['product_name']); echo $pn; //Output: " sony ericsson, w995 black"
  12. What is so hard to understand? Hotmail does not suppress images by default. You need to turn that option on. MSN Hotmail Help So, use an image if you want, but doing so will prevent you from tracking anyone who has images suppressed in their emails.
  13. <html> <head> <script type="text/javascript"> function showField(fieldID, showBool) { document.getElementById(fieldID).style.visibility = (showBool) ? '' : 'hidden'; } </script> </head> <body> <select name="something" onchange="showField('other', this.value=='4');"> <option value="0" selected="selected">--- Please Select ---</option> <option value="1">option 1</option> <option value="2">option 2</option> <option value="3">option 3</option> <option value="4">Other</option> </select><br /> <input type="text" name="other" id="other" style="visibility:hidden;" /> </body> </html>
  14. What is your question? you say you were able to do it once successfully, so you "could" do the same for the rest, correct? I will however make a few suggestions. Since you have a many-to-one relationship I would suggest putting the 'shows_Selected' values into a secondary table with a reference back to the parent record - rather than concatenating all the values into a single value in the database. The current method you are using loses some of the integrity of the data. However, that aside, your current process of concatenating the values is inefficient as well. You could replace this $media_array = $_POST['shows_Selected']; foreach ($media_array as $one_media) { $source .= $one_media."<br>"; } $shows_Selected = substr($source, 0, -2); with just this $shows_Selected = implode('<br>', $_POST['shows_Selected']); I also notice you are storing three different values for the wedding day/month/year. You can just store a single timestamp value instead of all three. then parse that value for day/month/year as needed.
  15. When a form submits when you have a return false to prevent it from doing so, that typically points to a javascript error that is occurring - which prevents the return false from triggering. In this case I see at least one problem on the button object. You are defining the onclick function within single parens, but then you have parameters inside the onclick trigger action that also has single parens. Once the processor hits the 2nd single paren it thinks that is the end of the trigger code. Try this <button onclick="$('ta').submit(); get_value();">update</button>
  16. You need to use the word boundry keyword: \b I couldn't get it to work with eregi, but I could with preg_match(). $userText = "Hi there"; //Would return true in the test below $userText = "Hit this"; //Would NOT return true in the test below $botSearch = '/\bhi\b/i'; //Added i at the end to make case insensitive if(preg_match($botSearch, $userText)!==0) { echo "Found the WORD 'hi'"; }
  17. I was not stating that the email client would open the document automatically. The question was to find out who "opened" the newsletter. I stated one possible option was to have the attachment to include some sort of link in it (such as to an image) which it would load when the document was opened. I am not suggesting this as a "best practice" solution because it could be seen as underhanded and I'm not sure how difficult it would be to dynamically create these documents each with a different link for each user. I still think the best solution is to have a link in the email to the user and the link opens the newsletter (HTML, PDF, etc.) but the link will include the cutomer ID or some other identifying information. When the request for the document hits the server you can grab that identifier. It's really the same logic as the embedded images in the email, but won't be blocked by the email client.
  18. EDIT: nm
  19. Well, I can provide a couple examples. But, if you have a document type where you can include a link to an image or some other element, which will load when the document is opened, AND you can dynamically create the document then you could create a different document for each recipient with a different link. That way when the user opens the document, then when the document attempts to load the image (or other object) then you could capture who opned the newsletter. It all depends on whether the document supports link to external objects. I know that it could be done with MS Word, but trying to create those dynamically may be problematic. Again, the easiest implementation would be to just include a link to an HTML version of the newsletter hosted on your server. Each email would include a slightly different link, such as www.mysite.com/getNewsletter.php?u=12345 Then that page will get the user ID from the $_GET values and you can track accordingly.
  20. This is not a SESSION variable error. You are not using the session variable in the code - only setting it. 1. Are you getting any errors? 2. Have you checked the generated HTML of the form to ensure the hidden field does have a value 3. Verify the POST values on the processing page by adding this before the if statement: echo "<pre>"; echo print_r($_POST); echo "</pre>"; EDIT: So, what IS the problem? If all the POST data is available on the processing page, then the ID number is there, right?
  21. Hmm, well since you have thousands of records I'm assuming you need put put the results into an array as you can't store multiple names into a single variable (i.e. $lastName). No offense, but I see a couple problems with slapdashwebdesigner's code. For example, the regex expressions will fail since the forward slashes are not escaped. But, more importantly, the code assumes that ALL the text on the page is in fact part of the data. After all the table tags are stripped you would much of the structure. The following code is more verbose, but has more logic in it. For example, you can set it to only look for data in a specific table - or leave as is and it will process all tables, but only the tables. The script will process an entire 'page' and put the results into a multidimensional array. Each element is a different record. See an example of the output at the end. Just add more options/conditions to the switch() as needed. <?php //Read the file as an array $html = file('test.htm'); //Output for the resuls $results = array(); //Vars for tracking the data $inTable = false; $inRecord = false; $recordIdx = 0; $dataIdx = 0; foreach($html as $line) { //echo "1"; //Determine if inside of table if (!$inTable) { //If looking for a SPECIFIC table, add add'l verification //for example, you can check table name if (strpos($line, '<table')!==false) { $inTable = true; } } if ($inTable) { //Determine if in a new row/record if (!$inRecord && strpos($line, '<tr')!==false) { $inRecord = true; } //Look for a data line if ($inRecord && strpos($line, '<td')!==false) { preg_match('/<td>(.*)<\/td>/', $line, $match); $data = trim($match[1]); switch($dataIdx) { case 0: //Last, First names $results[$recordIdx]['lastName'] = trim(substr($data, 0, strpos($data, ','))); $results[$recordIdx]['firstName'] = trim(substr($data, strpos($data, ',')+1)); break; case 1: //email $results[$recordIdx]['email'] = $data; break; case 2: //var1 $results[$recordIdx]['var1'] = $data; break; case 3: //var2 $results[$recordIdx]['var2'] = $data; break; } $dataIdx++; } //Determine if end of row/record if ($inRecord && strpos($line, '</tr')!==false) { $inRecord = false; $recordIdx++; $dataIdx = 0; } } //Determine if end of row/record if ($inTable && strpos($line, '</table')!==false) { $inTable = false; } } echo "<pre>"; print_r($results); echo "</pre>"; ?> Example output Array ( [0] => Array ( [lastName] => Smith [firstName] => Bob [email] => bob@smith.com [var1] => male [var2] => 32 ) [1] => Array ( [lastName] => jackson [firstName] => Michael [email] => michael@damato.net [var1] => pedo@death.com [var2] => 50 ) [2] => Array ( [lastName] => Hayak [firstName] => Selma [email] => hottie@latin.com [var1] => female [var2] => 38 ) [3] => Array ( [lastName] => Moore [firstName] => Demi [email] => demi@something.com [var1] => female [var2] => 46 ) )
  22. Yes, but you'll probably need to use the regular expression object. The formatting of the regex is slightly different. But, here's an example: This would find if the letter 'O' appears twice in succession in a string: string.match(/O{2}/) To make the letter you are testing against dynamic, you could use the regular expression object. Notice that when creating the regex object that the beginning and ending forward slashes are dropped. Also, there are specific modification that need to be make for keywords. function matchCustom(string, searchStr) { var regEx = new RegExp(searchStr+'{2}') if (string.match(regEx)) { alert('true'); } else { alert('false'); } } See this page for more info: http://www.regular-expressions.info/javascript.html
  23. if(isset($_GET['upload'])&& !isset($_GET['edit_gal'])) { require_once('upload.php'); } elseif(isset($_GET['edit_gal'])) { mysql_select_db($database, $makeconnection); $query = "SELECT * FROM tbl_gallery g, tbl_subgallery s WHERE s.gal_id=g.gal_id ORDER BY s.gal_id"; $result = mysql_query($query) or die(mysql_error()); $sectionHeading = false; while ($row = mysql_fetch_assoc($result)) { if($sectionHeading != $row['gal_name']) { echo "<h1>{$row['gal_name']}</h1>\n"; $sectionHeading = $row['gal_name']; } echo "<p>{$row['subgal_name']}</p>\n"; } }
  24. Or just this for (count=1; count<=20; count++) { document.write(count+' - '+((count%2)?'Odd':'Even')+'<br />'); }
  25. OK, I see the problem now. But before I get to the real problem, I do notice that you run this line before you load the page to display the results: $numres = $connector->fetchRow($result); I would think that that line would "use up" the first record in the result set, not sure why you have it there. Anyway, the problem is that you are trying to loop through the result set twice - once for the city/state list and again for other data. You either need to reset the result set back to the first record OR pull all the data in one pass (my preference). I also notice that you don't seem to be using the state list. you have a label to select the state, but you are actually using the city list. I did not correct any of that: <?php $stateOptions = ''; $cityOptions = ''; $resultHTML = ''; while ($row = mysql_fetch_array($result)) { $stateOptions .= "<option value=\"{$row['state']}\">{$row['state']}</option>\n"; $cityOptions .= "<option value=\"{$row['city']}\">{$row['city']}</option>\n"; $resultHTML .= "<tr>"; $resultHTML .= "<td>{$row['city']}</td>"; $resultHTML .= "<td>{$row['state']}</td>"; $resultHTML .= "<td>{$row['npa']}-{$row['nxx']}-{$row['localnum']}</td>"; $resultHTML .= "<td>{$row['carrier']}</td>"; $resultHTML .= "</tr>\n"; } ?> <html> <head> <title>Result of Access Number search</title> <style type="text/css" media="screen"> @import "css.php"; </style> </head> <body> <table id="dbresult"> <thead> <tr> <th>City</th> <th>State</th> <th>Access Number</th> <th>Carrier</th> </tr> <tr> <th><form id="filter_city" action="access_check.php" onSubmit="return valid(this)" method="get" name="filter_city"> Select State: <select name="filter_city" id="filter_select" size="1"> <?php echo ($cityOptions); ?> </th> <th> </tr> </thead> <tbody> <?php echo $resultHTML; ?> </tbody> </table> </body> </html>
×
×
  • 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.