Jump to content

MadTechie

Staff Alumni
  • Posts

    9,409
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by MadTechie

  1. try this $text = 'Inspection number</th> <td>327355</td>'; if (preg_match('%Inspection number</th>\s*<td>(\d*?)</td>%sm', $text, $regs)) { $result = $regs[1]; }else{ $result = 'N/A'; } echo $result; EDIT: Delimiter must not be alphanumeric or backslash means you didn't add the delimiters (in my example i used %) so this would also be okay "\Inspection number</th><td>(*.?)</td>\",
  2. Ahh okay.. I think the problem is a syntax error on one of the lines of code or maybe the logical error, Now /".*?[.!?]"(.*?$)/sm Matches the character " literally " then Match any single character .*? Between zero and unlimited times, as few times as possible, expanding as needed (lazy) *? then Match a single character present in the list .!? [.!?] then Match the character " literally " then Match the regular expression below and capture its match into backreference number 1 (.*?$) then Match any single character .*? Between zero and unlimited times, as few times as possible, expanding as needed (lazy) *? Assert position at the end of a line (at the end of the string or before a line break character) $ SM: dot matches newline; ^ and $ match at line breaks Hope that helps LMAO
  3. Explain what you mean by "did not work" I did What part do you need more detail on?
  4. Ahhh that make more sense LOL, at least its working now Erm just one thing $message = $message = "- There was an error moving the file.<br>"; if your appending the text then surely this would be what you want $message .= "- There was an error moving the file.<br>";
  5. Well as your not getting an error 1,6 or 7, it seams the upload is fine, but accessing the file isn't working.. you could try this little script to see if you can access files, $tmpfname = tempnam("/tmp", "FOO"); if(is_readable($tmpfname ){ $handle = fopen($tmpfname, "w"); fwrite($handle, "writing to tempfile"); fclose($handle); unlink($tmpfname); } but personally i would seam to be a problem with permission, unless i am missing something
  6. The white screen is probably an error in your .htaccess file, have you tried adding the ini_set('memory_limit', '12M'); right above the line with the error.. However you may want to get a better host, as even if you get this to work, your host may just suspend your site for using too much resource. as I assume your on a shared host. of course the other option (if possible) is to change your code, so it uses less memory
  7. So the file failed to move ? I don't think you got the same error's I guess i should of added an else if(move_uploaded_file ( $_FILES['image']['tmp_name'], $temp)) { photo($temp,150,$img); unlink($temp); }else{ echo "Error moving file"; } I think upload_tmp_dir is only changeable via the php.ini file itself you could try it i guess ini_set('upload_tmp_dir','/new/path');
  8. http://www.php.net/manual/en/language.functions.php
  9. Kinda strange! try creating a tmp folder in the media folder (with write access) then move the uploaded file to it, ie $temp = dirname(__FILE__).'/../media/tmp/'.$rand.nomValide($_FILES['image']['name']); $img = dirname(__FILE__).'/../media/small/'.$rand.nomValide($_FILES['image']['name']); if(move_uploaded_file ( $_FILES['image']['tmp_name'], $temp)) { photo($temp,150,$img); unlink($temp); }
  10. What error ? What was it doing or not doing ?
  11. I have already posted a solution.. what's wrong with it ?
  12. Its a regular expression preg_match_all uses the regular expression to capture all of the results into an array see manual preg_match_all the regular expression i wrote does the following matches a " then anything up until a . or ! or ? followed by a " then captures everything to the end of the line
  13. like this ? <?php $string = '"This is first sentence." This is second. " This is second sentence. Which I dont want "This is first sentence." Blar. " This is second sentence. Which I dont want '; preg_match_all('/".*?[.!?]"(.*?$)/sm', $string, $result, PREG_PATTERN_ORDER); $result = $result[1]; var_dump($result); ?>
  14. Here's a quick update <?php session_start (); if (! isset ( $_SESSION ['myusername'] )) { header ( "location:main_login.php" ); exit (); } include '/header.php'; ?> <title>Our Models</title> </head> <body> <!-- Begin Wrapper --> <div id="wrapper"><!-- Begin Header --> <div id="header"> <h1><a href="http://www.bluesapphirestudios.com"><img src="../slanderbanner.jpg" border=0></a></h1> <br /> <?php echo "<strong><font color='#fffff'>Welcome " . $_SESSION ['myusername'] . "</font></strong> ... <a href='http://www.bluesapphirestudios.com/search/logout.php'>Logout</a>"; //pointless (as the page redirects if user isn't logged in /* if (isset ( $_SESSION ['myusername'] )) { echo "<strong><font color='#fffff'>Welcome " . $_SESSION ['myusername'] . "</font></strong> ... <a href='http://www.bluesapphirestudios.com/search/logout.php'>Logout</a>"; } else { echo "<a href=\"http://www.bluesapphirestudios.com/search/main_login.php\">Login</a>"; }*/ ?> </div> <!-- End Header --> <?php include '/menu2.php'; ?> <div id="rightcolumn"><br /> <br /> </h3> <form method="post" action="sqlsearch.php">Search Models: <input type="Text" name=".$Search" size="20" maxlength="30"> <input type="Submit" name="submit" value="Search"></form> </div> <?php include '/footer.php'; ?> <?php $host = "HOST"; // Host name $username = "USERNAME"; // Mysql username $password = "PASSWORD"; // Mysql password $db_name = "DBNAME"; // Database name $tbl_name = "TABLENAME"; // Table name // Connect to server and select databse. mysql_connect ( $host, $username, $password ) or die ( "cannot connect" ); mysql_select_db ( $db_name ) or die ( "cannot select DB" ); // username and password sent from form if (get_magic_quotes_gpc()) { $myusername = stripslashes($_POST['myusername']); $mypassword = stripslashes($_POST['mypassword']); } else { $myusername = $_POST['myusername']; $mypassword = $_POST['mypassword']; } $sql = sprintf("SELECT * FROM $tbl_name WHERE username='%s' and password='%s' LIMIT 0,1",mysql_real_escape_string ( $myusername ),mysql_real_escape_string ( $mypassword )); $result = mysql_query ( $sql ); // Mysql_num_row is counting table row $count = mysql_num_rows ( $result ); // If result matched $myusername and $mypassword, table row must be 1 row if ($count == 1) { session_start(); // Register $myusername, $mypassword and redirect to file "search.php" $_SESSION ['myusername'] = $myusername; header ( "location:search.php" ); exit; } else { echo "Wrong Username or Password"; } ?>
  15. It maybe an idea to post the full script.. for review
  16. session_register("myusername"); session_is_registered("myusername"); is kinda old (PHP4) try <?php if(isset($_SESSION['myusername'])){ echo "<strong><font color='#fffff'>Welcome ".$_SESSION['myusername']."</font></strong> ... <a href='http://www.bluesapphirestudios.com/search/logout.php'>Logout</a>"; }else{ echo "<a href=\"http://www.bluesapphirestudios.com/search/main_login.php\">Login</a>"; } ?> also change session_register("myusername"); to $_SESSIOIN['myusername'] = $myusername; EDIT: also you need to have session_start(); at the start of your code to use sessions
  17. And this ? <?php $dom = new DOMDocument; @$dom->loadHTMLFile('http://rapidshare.com/users/IZF0LP'); $xpath = new DOMXPath($dom); $aTag = $xpath->query('//a[contains(@href, "http://rapidshare.com/files")]'); $list = array(); foreach ($aTag as $val) { //echo $val->getAttribute('href') . ' => ' . $val->nodeValue . "<br />\n"; $list[] = $val->getAttribute('href'); } //remove dups from array here $clean = array_unique($list); foreach ($clean as $val) { echo $val . "<br />\n"; } ?> $list = 184 $clean = 94 items
  18. LOL, I kinda guess your know cags, it was more a comment for Tuck
  19. Personally i have mysql_query("SET CHARACTER SET utf8"); mysql_query("SET NAMES utf8"); on the same place as connection to the database
  20. Okay.. this is the reason we have single quotes and double quotes a double quote allows variables to be parsed where as singles don't ie $avar = "MadTechie"; echo "1. Hello $avar "; echo "<br>";//line break echo '2. Hello $avar '; So to fix this you can either start with double quotes or concatenate the string ie echo '<strong>'.$avar.'</strong>'; or echo '<strong><font color=\'#000000\'>Welcome '.$session_is_registered['myusername'].'</f...snip'; EDIT: mikesta707 beat me to it but worth posting i think
  21. as you started with single quotes you need to escape the single quotes (or just change the start and end doubles to singles)
  22. echo '<strong><font color='#000000'>Welcome $session_is_registered[myusername]</font></strong> ... <a href="http://www.bluesapphirestudios.com/search/logout.php">Logout</a>'; okay you are using both single and double quotes you can break it up into multiple lines or escape the quotes if you start with echo " you need to escape the " ie \" if you start with echo ' you need to escape the ', ie \' EDIT: i'll start you off (single quote escaped) echo '<strong><font color=\'#00.....snip......';
  23. seams okay what error are you getting ?
  24. Cont. from cags PHP option header('Content-type: text/html; charset=utf-8');
  25. I'm not sure what your asking... Don't do a str_replace to replace ' with \', use mysql_real_escape_string $string = mysql_real_escape_string($string); $query = "INSERT INTO `table` (`string`) VALUES ('$string')";
×
×
  • 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.