Jump to content

w1ww

Members
  • Posts

    33
  • Joined

  • Last visited

    Never

Everything posted by w1ww

  1. It is generated by a CMS, I can't hack the core. I get the list in a variable.
  2. I've a dynamically generated html list like this one: <ul> <li><a href="#">Item 1</a> </li> <li>Item 2<ul> <li>Item 2.1 <ul> <li><a href="#">Item 2.1.1</a> </li> <li><a href="#">Item 2.1.2</a> </li> <li><a href="#">Item 2.1.3</a> </li> <li><a href="#">Item 2.1.4</a> </li> <li><a href="#">Item 2.1.5</a> </li> </ul></li> <li><a href="#">Item 2.2</a> </li> <li><a href="#">Item 2.2.1</a> </li> <li><a href="#">Item 2.2.2</a> </li> <li><a href="#">Item 2.2.3</a> </li> <li><a href="#">Item 2.2.4</a> </li> <li><a href="#">Item 2.2.5</a> </li> </ul></li> <li>Item 3 <ul> <li><a href="#">Item 3.1</a> </li> <li><a href="#">Item 3.1</a> </li> </ul></li> <li>Item 4 <ul> <li><a href="#">Item 4.1</a> </li> <li><a href="#">Item 4.2</a> </li> <li>Item 4.3 <ul> <li><strong class="selflink">Item 4.3.1</strong> </li> <li><a href="#">Item 4.3.2</a> </li> </ul></li> </ul></li> <li><a href="#">Item 5</a> <ul> <li><a href="#">Item 5.1</a> </li> <li><a href="#">Item 5.2</a> </li> <li><a href="#">Item 5.3</a> </li> <li><a href="#">Item 5.4</a> </li> <li><a href="#">Item 5.5</a> </li> </ul></li> </ul> I need to add another "li" before the last "</ul>". How can I do it? Regex or ..? Thanks in advance
  3. Hey, Imagine that I've a text file like: Name: John Doe Age: 38 Place of Birth: New York How can I, for example, get the age of the guy? Thanks in advance .
  4. Hello, Can you guys help me a little bit with this (PHP). Imagine that I've this html code: <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="437" height="288" id="viddler_aae0f0d6"><param name="movie" value="http://www.viddler.com/player/aae0f0d6/" /><param name="allowScriptAccess" value="always" /><param name="allowFullScreen" value="true" /><embed src="http://www.viddler.com/player/aae0f0d6/" width="437" height="288" type="application/x-shockwave-flash" allowScriptAccess="always" allowFullScreen="true" name="viddler_aae0f0d6" ></embed></object> I want to extract the id field id="viddler_aae0f0d6". How can I do this knowing that every time the id it's going to be different? So basically I want to extract "viddler_aae0f0d6" from this code. Anyone has ideas? I know that this can de done with regular expressions but I'm not sure of how to do it. Regards!
  5. Oh yes, I see. Thank you! Just learned a new thing !
  6. Hello, I've a quick question: $cats = array(1,2,3); and $b = 1,2,3; array($b); They produce different results, but what I want is that when I do array($b) it should show work as array(1,2,3) and it shouldnt turn the first position of the array in 1,2,3. I hope this is clear. Thank you help
  7. It does not work (thank you for trying). What I get is the first 10 results and not the last ones of the database.
  8. Hello, I'm here stuck on this query: $q = "SELECT * FROM mensagens WHERE codSala='$sala' ORDER BY data ASC" I want to get the last 10 results ordered by date where the 1st result is the oldest and the last one is the latest. How can I done that? Thank you
  9. Hello, Imagine that I want to know what will be the date on the Thursday of week #27 of an year? For example, now is week #27, year 2008 and the date on Thursday was 03-07-2008 (dd-mm-yyyy). How can I do that? Thanks in advance, Tiago
  10. Oh! Thanks! And I just spent 3 hours on this!
  11. Hello, I'm trying to add some records to a database but it's not working and I don't why.. Can somebody check the code, please? I think the error in the query because I always get the die function error "There is a problem with our...". if (isset($_POST['continue'])){ // Caso contrario processa o form include("db.php"); // open connection $connection = mysql_connect($host, $user, $pass) or die ("No connection!"); // select database mysql_select_db($db) or die ("No database?!"); // variaveis $fname = mysql_escape_string($_POST['fname']); $lname = mysql_escape_string($_POST['lname']); $mail = mysql_escape_string($_POST['mail']); $logoname = mysql_escape_string($_POST['logoname']); $slogan = mysql_escape_string($_POST['slogan']); $description = mysql_escape_string($_POST['descri']); $website = mysql_escape_string($_POST['website']); $other = mysql_escape_string($_POST['other']); // create query $query = "INSERT INTO order (name, lastName, email) VALUES ('$fname', '$lname', '$mail')"; $result = mysql_query($query) or die ("There is a temporary problem with our service. Please try again later."); $orderid = mysql_insert_id(); $query = "INSERT INTO projects (logoText, slogan, description, other, website, orderID) VALUES ('$logoname', '$slogan', '$description' ,'$other' ,'$website', '$orderid')"; $result = mysql_query($query) or die ("There is a temporary problem with our service. Please try again later."); // close connection mysql_close($connection); } Thanks!
  12. That was the problem! I was coding with dreamweaver. Thanks a lot!
  13. Warning: Cannot modify header information - headers already sent by (output started at D:\wamp\www\pandalho\index.php:1) in D:\wamp\www\pandalho\index.php on line 5 This is the right error. Sorry. In the first line there is a single <?php tag without any spaces! Thank you!
  14. Hello. I searched google and found that the headers already sent problem error is returned if theres a white space. Still, on my script there's nothing on the first line. <?php ob_start(); $inTwoMonths = 60 * 60 * 24 * 60 + time(); setcookie('lastVisit', date("Y-m-d G:m:s"), $inTwoMonths); ob_end_flush(); //show form if (!isset($_POST['sub'])){ ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd"> <html> <META http-equiv="Content-Type" content="text/html; charset=UTF-8"> <head><title>Ajuntamento do Pandalho</title> This are the first lines of my script. Why do I keep getting "Warning: Cannot modify header information - headers already sent by (output started at D:\wamp\www\pandalho\index.php:1) in D:\wamp\www\testing\index.php on line 5" Thank you.
  15. Hello Freaks ! I'm trying to use the yahoo search api, that returns a XML file and I've this script to phrase the XML, but the script returns a blank screen: (You can see an example of what the yahoo returns here: http://search.yahooapis.com/WebSearchService/V1/webSearch?appid=YahooDemo&query=madonna&results=2) <?php $key = "MYKEY"; $query = "something"; $language = "en"; $url = "http://search.yahooapis.com/WebSearchService/V1/webSearch?appid=".$key."&query=".$query."&results=10&language=".$language.""; $count = 10; //* get the xml file $xml = simplexml_load_file($url); //* phrase all the data from the xml so we can display it for ($x = 0; $x < $count; $x++) { //* this bits for if its an rss 1 feed if (isset($xml->item)) { $item = $xml->item[$x]; } //* this bits for 0.91 rss feeds elseif (isset($xml->Result->item)) { $item = $xml->Result->item[$x]; } //* show the headline and the description echo "<a href=\"$item->Url\">$item->Title</a><br>$item->Summary<br><br>"; } //* reset variables unset($xml); unset($item); //* close the function loop ?> Thank you!
  16. Oh thank you You saved my day ! Someone please close the topic!
  17. Hello, This is a login script, everything works fine but when I login the session does not start so I get the message 'You're not in'.. Whats wrong? Here is the code for login and the test page: The login page: <? ob_start(); require_once($_SERVER['DOCUMENT_ROOT'].'/reg/db_connect.php'); if(isset($_SESSION['username']) && isset($_SESSION['password'])) { //REDIRECT TO USERS PROFILE... header("Location: test.php"); } //end if logged in //IF SUBMIT BUTTON PRESSED if(isset($_POST['submit'])) { if(!$_POST['username']) die("Error: You must enter your username before logging in."); if(!$_POST['password']) die("Error: You must enter your password before logging in."); //set cookie if checked if(!empty($_POST['stay_in'])) { $joined =''.$_POST['username'].'[]'.md5($_POST['password']).''; setcookie('login_cookie', $joined, 2147483647, '/', '.test.php'); } //end if //verify user... $get_user = mysql_query("SELECT * FROM `members` WHERE username = '".$_POST['username']."' AND user_password = '".md5($_POST['password'])."'"); $q = mysql_fetch_object($get_user); if(!$q) die("Login Failure: An error occured, please verify your username and password are correct."); //set session variables $_SESSION['logged_in'] = 1; $_SESSION['username'] = $_POST['username']; $_SESSION['password'] = $_POST['password']; session_write_close(); header("Location: test.php"); } else { //show login form ?> <form name="login" method="post" action="<? $_SERVER['PHP_SELF']; ?>"> <table> <tr> <td>Username:<input type="text" id="username" name="username"></td> </tr> <tr> <td>Password:<input type="password" id="password" name="password"></td> </tr> <tr> <td>Submit: <input type="submit" value="Submit" name="submit" id="submit"></td> </tr> <tr> <td>Remember? <input type="checkbox" name="stay_in[]" checked="yes"></td> </tr> </table> </form> <? }//end else ?> The test page with page headers: <? ob_start(); session_start( ); require_once($_SERVER['DOCUMENT_ROOT'].'/reg/db_connect.php'); //check cookie if ($_SESSION['logged_in'] != 1 && isset($_COOKIE['login_cookie'])) { list($user, $pass) = explode('[]', $_COOKIE['login_cookie']); $qu = mysql_query("SELECT `user_password` FROM `members` WHERE `username` = '".addslashes($user)."'"); if (mysql_num_rows($qu) == 1) { $passw = mysql_fetch_object($qu); if ($passw->user_password == $pass) { $_SESSION['logged_in'] = 1; $_SESSION['username'] = $user; $_SESSION['password'] = $pass; } } } if(!isset($_SESSION['username']) && !isset($_SESSION['password'])) { $_SESSION['logged_in'] = 0; $user = "Guest"; } // Lets see if we are in if ($_SESSION['logged_in'] == 1) { echo ("You're in"); } else { echo ("You're <b>NOT</b> in."); } ?> Can someone please check the code? Thanks for the help!!
  18. So ok, including the file the image is printed buut, somehow, a '1' is printed after the text .. :\ I arealy checked the code and the one just appears if I include files. [code]<?php function stringForJavascript($in_string) {   $str = ereg_replace("[\r\n]", " \\n\\\n", $in_string);   $str = ereg_replace('"', '\\"', $str);   Return $str; } switch($_GET['id']) { case 'tab1': $content = include "lol.php"; break; case 'tab2': $content = include "2.php"; break; case 'tab3': $content = 'Mais uma aqui.'; break; case 'tab4': $content = 'LAalalla.'; break; default: $content = 'There was an error.'; break; } print stringForJavascript($content); usleep(400000); ?>[/code] -------- Code for lol.php [code]<p><img src="teste.jpg" alt="" style="float: left; margin: 0px 6px 3px 0px;" class="borderimage" />Lorem ipsum dolorsit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio.</p>[/code]
  19. I wasn't sure about it, thank you! About the image nothing? Many thanks
  20. [code]<?php function stringForJavascript($in_string) {   $str = ereg_replace("[\r\n]", " \\n\\\n", $in_string);   $str = ereg_replace('"', '\\"', $str);   Return $str; } switch($_GET['id']) { case 'tab1': $content = '<p><img src="teste.jpg" alt="" style="float: left; margin: 0px 6px 3px 0px;" class="borderimage" />Lorem ipsum dolorsit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio.</p>'; break; case 'tab2': $content = 'Outra Aqui.'; break; case 'tab3': $content = 'Mais uma aqui.'; break; case 'tab4': $content = 'LAalalla.'; break; default: $content = 'There was an error.'; break; } print stringForJavascript($content); usleep(400000); ?>[/code] This is an ajax script, everything works, but the image just doesnt show up! Can I include pages at the $content var ? If yes, can you tell how do it? Thank you
  21. yes: [code]print stringForJavascript($content);[/code]
  22. Hello I've this: [code]$content = '<p><img src="teste.jpg" alt="" style="float: left; margin: 0px 6px 3px 0px;" class="borderimage" />Lorem ipsum dolorsit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio.</p>';[/code] The image its not showing up, why? :s Oh another question, am I able to include pages inside the $content ? Thank you!
×
×
  • 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.