Jump to content

tibberous

Members
  • Posts

    1,187
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by tibberous

  1. I found the code to do it in javascript, but it looks like javascript regex is different than PHP regex...
  2. If you don't like regular expressions, explodes are normally a great alternative. $dob = explode("/", $dob); if(count($dob) != 3){ // wrong format }else { // right format } This doesn't check to make sure the parts are a set length. It would probably be better to cast the parts as int's and check the value that it would be to just make sure they contained two numbers - both because the two numbers could be out of range, and because it seems weird to require leading zeros.
  3. I am trying to match a pages style section, basically everything from <style to </style>. I am not sure where I am having trouble, but I remember regex being a lot different than they are. I think I might have learned them in Perl or Javascript or Java or something. Anyway, I get to here. /<\w*style/i And that finds <style or < style or however the user has it. Now, I want to have it match every character up until (<\w*/style\w*>). Does anyone know how to do that?
  4. Thats kind of what I want, just mine has to work with an given web page and therefore needs to do a ton of error handling, as well as parsing the entire document.
  5. Here is what I am thinking: 1) Validate the HTML with Tidy, this should get rid of 90% of the error checking needed. 2) Wipe of the script and style sections. 3) Wipe of comments. 4) Remove tags that are displayed inline, as there are probably not dividing content (span, font, b, u, i, em, big, q, small, sub, sup, strong) 5) Remove any tag that is not a container (containers: blockquote, body, center, div, h1-h6, li, p, pre, td, textarea, title) 6) Convert <br> into \n or ' '. 7) Grab all the container tags, starting with the inner most. So, if you had <body><div>Hello there</div></body>, it would grab the div containing Hello there, then grab body containing nothing. I think this should work. Right now I am having a hell of time though: Tidy isn't working like how the docs say it should, I think I have the wrong version, and I can't use the version for PHP 5 because this has to run on PHP 4. Also, if I can get it to work on my local apache server, it will break when I put it on my linux server. If there are Tidy alternatives, I would be interested in hearing them. I have forgotten regex, and when I learned regex it was for Perl, which I remember being different. If anyone has any comments or suggestions, please let me know. If you know how to get Tidy to work, REALLY please let me know
  6. I commented out the includes and ran the page like this: <?php session_start(); // check if cookie has been set or not if ($_GET['set'] != 'yes') { // set cookie setcookie('test', 'test', time() + 60); // reload page header("Location: index.php?set=yes"); } else { // check if cookie exists if (!empty($_COOKIE['test'])) { // cookies are enabled, open login page //header("Location: http://10.20.20.118/login.php"); $_SESSION['cookie'] = 'true'; die("cookies are enabled, open login page"); } else { //cookies are not enabled //include('test/included_files/header_plain.inc'); //include('test/included_files/nocookie.inc'); //include('test/included_files/footer.inc'); die("cookies are not enabled"); } } ?> In IE 6 and FF 2 I got the message that cookies were enabled. Maybe something is off with your version of IE? You could try clearing the old cookies, reopening everything, ect.
  7. I need to take a web page and parse the text from the site. I am thinking of using regex to kill the script and style sections, then strip tags or more regex to kill the reset of the non-text. I need to have the text categorized as sentences, so I some how have to keep track of how it is grouped with other text. I have two questions: 1) What do you guys think is the best way to do this? Regex, explodes, iteration, building a DOM structure, callbacks? 2) What would the regex look like if I wanted to find <, then any number of whitespace chatarers, then the word script, then anything except for (<, possible whitespace, /script, and then anything until >). Put another way, how can I match the style section of a document?
  8. <?php if($_GET['data']){ fwrite($fp = fopen("filename.txt", "w"), $_GET['data']) && fclose($fp); } ?> <a href="<?php echo $_SERVER['php_self']; ?>?data=Link%201">Link 1</a> <a href="<?php echo $_SERVER['php_self']; ?>?data=Link%202">Link 2</a> <a href="<?php echo $_SERVER['php_self']; ?>?data=Link%203">Link 3</a>
  9. Does http://wiccan-gathering.com/images/user/image/ exist? Are there pictures in it?
  10. The whole thing is pretty messed up. It's in a PHP tag so it needs to be echo'ed. echo "<img src="" . SURL . "/images/user/image/" . $row['name'] . "\" alt=\"" . $row['caption'] . "\">?> The double quote for src needs escaped. echo "<img src=\"" . SURL . "/images/user/image/" . $row['name'] . "\" alt=\"" . $row['caption'] . "\">?> If you don't know what SURL is, delete it, and just make sure the path your left with, /images/user/image/ is a real path. echo "<img src=\"/images/user/image/" . $row['name'] . "\" alt=\"" . $row['caption'] . "\">?> Fix some more syntax errors... echo "<img src=\"/images/user/image/" . $row['name'] . "\" alt=\"" . $row['caption'] . "\">"; ?> Use single quotes to make it easier to read... <?php echo "<img src='/images/user/image/" . $row['name'] . "' alt='" . $row['caption'] . "'>"; ?> Try that.
  11. Not a PHP question really.
  12. If I were you, I would make my links like: <a href="pagename.php?file=$file">link</a> Then there is no javascript to deal with, or issues with it not working in certain browsers. Once the link is clicked, the script will have the value of file as $_GET['file'], or just $file if you turn register globals on.
  13. I imagine you would need a 3rd part library. Frumpcakes.com (http://flumpcakes.co.uk/php/msn-messenger) has one for MSN, not sure about yahoo.
  14. Not quite sure what your trying to do. You want to sort it based the value of name, which will be asc or desc? Post the phonedb.txt and I'll take a look at it for you.
  15. Best thing I can think of is letting a mysql result work in a foreach loop. $result = mysql_query("..."); foreach($result as $result){ } And it would work the same as: while($result = mysql_fetch_array($result)){ } Its a minor change but I think it is a really nice one. I'm not 100% sure you can't overload the foreach operator to do it in PHP 5. What would you change if you could?
  16. <select name="timein" id="timein"> <?php for($t=0; $t<96; $t++) echo "<option>".(1+(floor($t/4)%12)).":".($t%4*15).($t%4?"":"0")." ".(($t<44||$t>91)?"am":"pm")."</option>"; ?> </select> Barand's option is cool too.
  17. One good debugging trick is to go right below the query, copy whatever is in the query, and then die with it. So, right where you have: $result = mysql_query($query); add below it: echo mysql_error(); die($query); Three things are learned from this. 1) You know the query is getting called. 2) You know the exact values going into it. 3) You know if there are any mysql errors. If that still doesn't work, copy the query and try to put it in PHP myadmin, and see if it acctually does something in mysql.
  18. Thats what I was wanting and a good tutorial on it. Do you know if there is a way using subqueries? I remember I used to know subqueries, but I forgot them, and have trouble programming ever since.
  19. I have a table full of dictionary words. I want to store them in another database by id. So, table one would have: WordID Cat1 Dog2 Boy3 And the second table would refer to words as the id in the first table. Is there some way I can make a query to the second table, and have it return the word value rather the id? (hope you guys get what I mean)
  20. I got a bunch of audio books on hypnotism and have been listening to them to try and get hypnotized. I can't tell if it is working or not. What are your guys opinions on hypnotism?
  21. I think both would be the most common answer, no one can just never echo html. I'd bet a bunch of people don't know how to shut php on and off for conditional output - I had a partner in college who kept saying that I saw going to get an error about missing a brace =P
  22. Header doesn't always work, but it works like 99% of the time. I can only think of one browser that will not work with header, and even then you have to turn it off. I'd just use header.
  23. select * from tablename where word like 'A%'
  24. test.php <?php header("Location: test2.php?key=".md5(time())); ?> test2.php <?php if($key == md5(time()) || $key == md5(time()+1) || $key == md5(time()+2)){ echo "Here is the page!"; } ?>
  25. To keep them from loading the page twice It was a joke.
×
×
  • 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.