Jump to content

Mr_CHISOL

Members
  • Posts

    404
  • Joined

  • Last visited

Everything posted by Mr_CHISOL

  1. You can remove while(!connection_aborted()) Than it shouldn't load forever.You may also want to remove set_time_limit( 0 );
  2. Mr_CHISOL

    Protecting emails

    rand() (http://php.net/manual/en/function.rand.php) simply gives you a random number.You can give rand() a min and max value (inclusive) if you want the number to be in a specific range.In this case we use rand do give the variable in the JS random names, to avoid that bots recognize them.
  3. Mr_CHISOL

    Protecting emails

    Yes the code is ok.Some note on reg.exp: you could remove the square brackets from the expression, as they are ment to group characters (see bellow): $r2 = preg_split("/@/", $r['email'] ); you could (if you want), replace preg_split() with explode(), as you don't need the reg.exp.: $r2 = explode("@", $r['email'] ); Here's some small examples on req.exp: /abc/ > matches a string that contains abc such as: "this is abc.com"/^abc/ > matches a string that starts with abc: "abcdef"/abc$/ > matches a string that ends with abc: "this is my abc"/^abc$/ > only maches abc: "abc"/a.c/ > matches a string that contains a[something]c: "abc" "acc" "adc" etc/a.*c/ > matches a string that contains a[any number of characters]c: "abbbbbc" "acccccc" "a here could be a b c" "ac" etc/a[bB]c/ > matches a string that contains a[b or B]c: "aBc" "abc" "AaBcC" etc/a[A-Z]*c/ > matches a string that contains a[any number of upper case letters]c: "ac" "aBc" "aABCDEFc" "aXYZc" etc/a[0-9]+c/ > matches a string that contains a[a number]c: "a0c" "a123c" "a42c" etc, but not "ac" That was some examples, which could be used in many different combinations (Perhaps unnecessary, but you, or someone else, could find it helpful...)Good Luck and Don't Panic!
  4. Hm, Not sure I followed, but:if fName is empty, then you get an error, if it's not empty, you don't get the error! right?Isn't that what you want it to do?Besides; you are testing the return of ctype_alpha() with an empty string, when it returns a boolean: if (ctype_alpha($fName) == "") $error .= "<p />Please fill in your first name.<br />";if ($error == "") info();else echo $error; Change it to if (!ctype_alpha($fName)) $error .= "<p />Please fill in your first name.<br />"; can't see any problems other than thatGood Luck and Don't Panic!
  5. Well there's two reasons to why it doesn't stop:1. the while-loop that waits for the connection to be aborted2. the time limit is set to zero (lets it go on for ever): set_time_limit(0); It seams that you've tried to make a chat-room. But the way you've done it is not very good.You will take a respecteble part of the server's cpu/power for your chat, especially if you get more users in your chat.Besides, it doesn't seam to work as it "should".One better way to do a chat is to use AJAX (http://www.w3schools.com/ajax/). Using AJAX you can simply update the chat from the server every second, without refreshing the page or having it load for ever. Using AJAX it's also qiut simple to send the messages to the server (which may be a problem using the script you have now).btwusing print "<A name='m$id'>"; isn't valid (no ending tag etc), try this: print "<a id='m$id'></a>"; Hope that helped...Good Luck and Don't Panic!
  6. Just try http://localhost/ or http://127.0.0.1
  7. Ehm, I'm not an expert, not eaven an user of it, on IIS and win.But this I know: IIS is a webserver for windows (not the greatest, use apache it's better, but it's better than PWS), and IE is a webbrowser...;?)
  8. Mr_CHISOL

    Find info

    $get_user = mysql_query("SELECT * FROM associnfo WHERE user_email = '".$_POST['em']."'");$q = mysql_fetch_assoc($get_user);if(!$q) die("FAILED. The email address does not exsist."); $to = "$em";$subject = "Your Password";$message = "<html>Your password is : ".$q['user_password']."<br />More Text";mail( $to, $subject, $message );echo "information send to the submitted email"; or $get_user = mysql_query("SELECT * FROM associnfo WHERE user_email = '".$_POST['em']."'");$q = mysql_fetch_object($get_user);if(!$q) die("FAILED. The email address does not exsist."); $to = "$em";$subject = "Your Password";$message = "<html>Your password is : ".$q->user_password."<br />More Text";mail( $to, $subject, $message );echo "information send to the submitted email"; Something like that (the last uses object and the first array/hash).
  9. Mr_CHISOL

    Protecting emails

    You could use preg_split() to split the email: $mail_arr = preg_split( "/[@\.]/", $mail ); The problem with that is if you have more than one dot in your mail-address you get more than three parts my.mail@host.com >> array( 'my', 'mail', 'host', 'com' ) To get arround this you can create a complex reg.exp., split it up by the @ first and then split up the second part (pref. using preg_split() and a good reg.exp..) or you could use strpos(), strrpos() and substr()...
  10. Mr_CHISOL

    Find info

    I see the problem (I think...).mysql_fetch_object() doesn't return an array, it returns an object.To get the values from the object yo must use this "format": $q->user_password If you want to use arrays/hashes you must use mysql_fetch_array() or mysql_fetch_assoc().
  11. Mr_CHISOL

    Loop

    No!The increment is done after the value is used (saved in the string in this case), when the operator (++) is after the variable.If the operator is before the variable (++$nr), the increment will be done before the value is used...
  12. Mr_CHISOL

    Protecting emails

    The bot scans the html and will find that email just as easy as it was written within the tag.One way is, as justsomeguy suggested, to use images to display the emails, this isn't too hard to do, just remember that you shouldn't display the email in the html: Not OK:<img src="showemail.php?email=my@host.com" />OK:<img src="showemail.php?id=42" /> Another way, if you want it clickable is to use javascript (together with PHP): <?php$rand1 = rand();$rand2 = rand();$rand3 = rand();$rand4 = rand();?><script language='JavaScript' type='text/javascript'> <!-- var prefix = 'ma' + 'il' + 'to'; var path = 'hr' + 'ef' + '='; var addy<?php echo $rand1 ?> = 'my'; var addy<?php echo $rand2 ?> = '_mail'; var addy<?php echo $rand3 ?> = 'host'; var addy<?php echo $rand4 ?> = 'com'; var addy<?php echo $rand5 ?> = addy<?php echo $rand3 ?> + '.' + addy<?php echo $rand4 ?>; addy<?php echo $rand5 ?> = addy<?php echo $rand1 ?> + addy<?php echo $rand2 ?> + '.' + <?php echo $rand5 ?>; document.write( '<a ' + path + '\'' + prefix + ':' + addy<?php echo $rand5 ?> + '\'>' ); document.write( addy<?php echo $rand5 ?> ); document.write( '<\/a>' ); //-->\n </script><script language='JavaScript' type='text/javascript'> <!-- document.write( '<span style=\'display: none;\'>' ); //--> </script>This email is protected against bots, you need to activate Javascript to view it... <script language='JavaScript' type='text/javascript'> <!-- document.write( '</' ); document.write( 'span>' ); //--> </script> You could perhaps find a better code if you used google..This should work fine as long as the bot doesn't support javascript (which not many does...)Good Luck and Don't Panic!
  13. Mr_CHISOL

    Find info

    It's not empty, youre adding a tag (<? ... ?>) that is treated as HTML and therefor not shown, you don't need the <? ?> and the echo simply just do like this: $to = "$em";$subject = "Your Pawword";$message = "<html>Your password is : {$q['user_password']}<br />... or $to = "$em";$subject = "Your Pawword";$message = "<html>Your password is : ".$q['user_password']."<br />... Whatever feels best for you
  14. Yes you do need to save it!And (for the third time...) Here's how to do it: $xml->asXML( 'filename.xml' ) :?)
  15. Well that's a way to do it, using JavaScript, (Note that only one element can have a id, use a class instead, or an id like id="page1"...) here's some ways to do it using PHP:1. Use one file (index.php) that you use the whole time (which Prateek sugested) and use someting like index.php?p=page1 This would simplify things a lot. See the below for more info 2. Use basename($_SERVER["SCRIPT_NAME"]); to see what page it is.Both those would be much simplier to do if you had the menu in a database, textfile or at least an array: $menu = array( 'Page 1' => 'page1.php', 'Page 2' => 'page2.php', 'Page 3' => 'page3.php' );echo "<ul>\n";foreach ($menu as $title => $page) { if ($page == basename($_SERVER["SCRIPT_NAME"])) $class = "nav_active"; else $class = "nav"; echo ' <li class="'.$class.'"><a href="'.$page.'">'.$title."</a></li>\n";}echo "</ul>\n"; To do the same using index.php?p=page use this: $menu = array( 'Page 1' => 'page1', 'Page 2' => 'page2', 'Page 3' => 'page3' );// If no page is given, set the first/start pageif (!isset($_GET['p'])) $_GET['p'] = 'page1';echo "<ul>\n";foreach ($menu as $title => $page) { if ($page == $_GET['p']) $class = "nav_active"; else $class = "nav"; echo ' <li class="'.$class.'"><a href="index.php?p='.$page.'">'.$title."</a></li>\n";}echo "</ul>\n"; Hope that helped...Good Luck and Don't Panic!
  16. Mr_CHISOL

    single cell query

    Hi!You could use mysql_fetch_assoc(), which basicaly is the same as mysql_fetch_array( $result, MYSQL_ASSOC ). while ($row = mysql_fetch_assoc( $result )) { echo "<tr>\n"; echo ' <td>'.$row['id']."</td>\n"; echo ' <td>'.$row["field1"]."</td>\n"; echo ' <td>'.$row["field2"]."</td>\n";} If you just want one row, remove the while-statement, but keep $row = mysql_fetch_assoc( $result ) Hope that helpedGood Luck and Don't Panic!
  17. Mr_CHISOL

    Loop

    Hi!The easiest way is to rename txt1,txt2 etc to txt[] (all to the same): <textarea name="txt[]"></textarea>or<input type="text" name="txt[]" /> and then loop thru them (you get $_POST['txt'] as an array): $txts = $_POST['txt'];foreach( $txts as $txt ) { $sql = "INSERT INTO submit_entry (entry_id, username, txt, condition) VALUES (' ', '$username', '$txt', 'contacted')"; $query=mysql_query($sql); if($query) echo " "; else echo "<b>ERROR</b>";} Note that you should only get those fields that has a value from the browser. If you want to be on the safe side you can add this to the loop: if (empt($txt)) break; It's always a good practice to avoid to the same thing over and over in your code, depending on the case/problem you can use loops (as in your case) or divide the code into functions (or both...)Hope that helped..Good Luck and Don't Panic!
  18. SimpleXML is be enabled by default (at least in PHP5+), but it may, for some unknown reason, be disabled on youre system.I don't now much about using PHP in M$ win (as I'm not a big fan of win...), so i don't know if there's a way to enable SimpleXML or DOM. One way to that is to update/reinstall with a new version of PHP (i.e.PHP 6) and make sure xml is enabled..
  19. Why shouldn't they?As long as you don't save to the file (using $xml->asXML( 'filename.xml' )) that would happen, as it loads in the same structure every time.If you DO save it and still get the same result, it's hard to tell what the problem is.
  20. Hi!You could use SimpleXML (which I preffer) and then do someting like this (using ->addChild()) $xml = new SimpleXMLElement('document.xml', NULL, TRUE);// add$xml->addChild('name', 'you');// save$xml->asXML( 'document.xml' ); If you want use DOM XML you could do something like this (i don't know that much about DOM XML) $doc = domxml_open_file("document.xml");$node = $doc->create_element("name");$newnode = $doc->append_child($node); Ok that's probalby wrong, I couldn't figure out how to do it... Go with SimpleXMLGood Luck and Don't Panic!
  21. Well, You don't have an id on content, but you have an id on poster.So if you change it to echo $xml[0]->post[0]->poster['id']; It should work fine.Or you could move the id to post: <?xml version="1.0" encoding="utf-8"?><posts> <post id="1337"> <poster>Yuval</poster> <content>Post content</content> </post></posts> echo $xml[0]->post[0]['id']; Don't Panic! :?)
  22. This may, again, be a long shot, but try to change return $xmlPath = $xmlValue;to return $xmlPath[0] = $xmlValue; or $classxml->updateXML($xml[0]->post[0]->content, "d");to $classxml->updateXML($xml[0]->post[0]->content[0], "d"); I would go with the last one. (To check if it's an array you can use is_array($xml[0]->post[0]->content) )
  23. Hm, I don't see a reason to why it doesn't work (how do you know it doesn't work? Do you use echo $xml->asXML(), or what do you do?)Try this:add echo (or var_dump()) in your function to see what it gets: function updateXML(&$xmlPath, $xmlValue, $attributeName = false) { echo 'XMLPath:'.$xmlPath.'; XMLValue:'.$xmlValue.'; AttrName:'.$attributeName."!\n"; if (!$attributeName) return $xmlPath = $xmlValue; elseif (trim($attributeName)) { //$this } } or function updateXML(&$xmlPath, $xmlValue, $attributeName = false) { echo 'XMLPath:'; var_dump($xmlPath) echo '; XMLValue:'; var_dump($xmlValue); echo '; AttrName:'; var_dump($attributeName); echo "!\n"; if (!$attributeName) return $xmlPath = $xmlValue; elseif (trim($attributeName)) { //$this } } What do you get then, do you see what you're expecting or something else...
  24. Hi!The reason it doesn't work is this:You send the value of $xml[0]->post[0]->content to updateXML() (stored in $xmlPath) and then change the value of $xmlPath to $xmlValue, you don't change $xml[0]->post[0]->content.To do you want uo need to use references (http://php.net/manual/en/language.references.php#language.references.whatare) change the declaretion of updateXML() to this: function updateXML( &$xmlPath, $xmlValue, $attributeName = false) {... Then it should work fine (note the ampersand).Hope that helped.Good Luck and Don't Panic!
  25. Hi!Indexing is something that may fasten up a search in a database, more info about should you be able to find here: http://dev.mysql.com/doc/refman/5.0/en/fulltext-search.htmlNote that there's a difference between index and indexing. Index is a way to sepperate different posts...NULL is a "non existing value". An empty value could be NULL (depending on the internal strutur of the programming language).In MySQL you can set a field as NULL or NOT NULL, which means that that field may be empty (NULL), or it isn't allowed to be empty (NOTNULL).Hope that helped some!Good Luck and Don't Panic!
×
×
  • Create New...