Jump to content

ronverdonk

Members
  • Posts

    277
  • Joined

  • Last visited

    Never

Everything posted by ronverdonk

  1. It is still not quite clear to me, but let's be practical: When you are looking form www.xxx.yy text that has to be converted into links, have a try at the following regular expression: <?php $pattern_url = '~(?>[a-z+]{2,}://|www\.)(?:[a-z0-9]+(?:\.[a-z0-9]+)?@)?(??:[a-z](?:[a-z0-9]|(?<!-)-)*[a-z0-9])(?:\.[a-z](?:[a-z0-9]|(?<!-)-)*[a-z0-9])+|(??:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?))(?:/[^\\/:?*"<>|\n]*[a-z0-9])*/?(?:\?[a-z0-9_.%]+(?:=[a-z0-9_.%:/+-]*)?(?:&[a-z0-9_.%]+(?:=[a-z0-9_.%:/+-]*)?)*)?(?:#[a-z0-9_%.]+)?~i'; $text = 'This is www.mysystem.com where the text can be found. Also at www.yourcom.nl you find some comments'; /** ----------------------------------------- Prefix www.xxxxx.yy string with http:// ----------------------------------------- */ preg_match_all($pattern_url, $text, $matches); for ($i=0; $i < count($matches[0]); $i++) { if (substr($matches[0][$i],0,4) == 'www.' ) $text = str_replace($matches[0][$i], 'http://'.$matches[0][$i], $text); } /** ---------------------------------------------------- Replace free-format URLs with <a href...> elements ---------------------------------------------------- */ $text = preg_replace($pattern_url,"<a href=\"\\0\">\\0</a>", $text); echo $text; ?>
  2. Something line: $a=array('id1','id2','id3','id4','id5','id6','id7','id8','id9','id10','id11','id12'); for ($i=0, $j=1; $i<count($a); $i+=2,$j+=2) { echo "<br>$a[$j]"; echo "<br>$a[$i]"; }
  3. In order to prevent possible 'undefined index' notices, you'd better code: $test = isset($_POST['carregistration']) ? $_POST['carregistration'] : null; etc
  4. Just do $_SESSION['lastid'] = mysql_insert_id();
  5. PHP manual: "setcookie() defines a cookie to be sent along with the rest of the HTTP headers. Like other headers, cookies must be sent before any output from your script (this is a protocol restriction). This requires that you place calls to this function prior to any output, including <html> and <head> tags as well as any whitespace. When the cookie is not set, a FALSE is returned." So I suggest that you check the result of setcookie() to check, as in: if (setcookie('uid', $row[0]['u_uid'], time() + $session_length) === false) {// this cookie isnt being set echo 'Setcookie failed'; exit; }
  6. To me you are switching the assignments, i.e. if (!isset($_POST['name'])) { $_POST['name'] = "name"; } should be if (!isset($_POST['name'])) { $name = $_POST['name']; } this goes for all the assignments from the $_POST array.
  7. Assuming you are talking about MySQL and "the ID generated for an AUTO_INCREMENT column by the previous query on success, 0 if the previous query does not generate an AUTO_INCREMENT value, or FALSE if no MySQL connection was established." (PHP manual) you can use the mysql_insert_id() function
  8. You have a webserver, XAMPP. That contains Apache, MySql, PHP and Perl. The webserver root is the root of your XAMPP installation, usually htdocs. Once you installed your clock in that root, you access it using the url localhost/progrname.php
  9. You are using single quotes there (witin a single quotes statement), so make the statement within double quotes: $query = mssql_query("SELECT Title, Surname, FirstName FROM PeoplesRec where Username = '$pnlusername' ");
  10. What format of links are we talking about: a. the a-tag link like <a href=xxxx>yyyyy</a> b. the url type such as http://www.mysite.com c. within bb-code such as [link=xxxxx]yyy[/link]
  11. I sure must be missing some code then: a. you specify no method, so the default method is GET b. you have no submit link or button, so it never gets submitted. All your code does now, as you have shown, is to show you some tables in a select box and the attributes of the last table in the select. So where is the submit button/link?
  12. Where do you submit the form? Btw: your form method is, by default, GET. So your $_POST will not work.
  13. Have you tried a regular expression (like preg_*) on your text data?
  14. So show us some of the code you have already made. I cannot guess!
  15. ALTER TABLE table_name DROP id; ALTER TABLE table_name ADD id INT NOT NULL AUTO_INCREMENT FIRST, ADD PRIMARY KEY (id), AUTO_INCREMENT=1; Ronald
  16. Change pattern to $pattern = "/^[A-Za-z]/";
  17. Use 2 counters: $i for the entire array and $j for the line no within a block, as follows: for($i=0,$j=1; $i<$num; $i++,$j++) { if (strlen(trim($lines[$i])) == 0) { $j=0; continue; } if($j == $line_to_extract) { echo 'Line '.$i.': '.$lines[$i].'<br />'; } } Ronald
  18. As petroz already said: $query = "SELECT * FROM airplanes WHERE ama='$ama'"; if (mysql_num_rows($result) == 0) { $errormsg = "error"; } elseif (mysql_num_rows($result) == 1) { include "display.php"; // from here it executes diisplay.php }
  19. Since you have already made 3 drop-down boxes, I do not see why you cannot insert a 4th one or, in your case, 1 'US state' box in-between 'countries' and 'cities'. Assuming you have one server routine that handles your requests, also that you pass the identifier of the <div> into which you save the result code to the JS routine. When you use "float:left" for these divs, all drop-downs will align nicely next to each other. If this is not the case, please show the code you have developed so far. Ronald
  20. Could $name_id contain a blank inbetween, like you are deleting on a numeric table field but the $name_id is CHAR and contains e.g. '1 2'?  That gives you a 1064 error. Ronald  8)
  21. The problem lies with the # sign used. So encode the url parm. See this snippet [code]A.PHP: <?php $a=urlencode("#123456"); echo "<a href='b.php?parm=$a'>Click</a>"; ?> B.PHP <?php echo ' parm='.urldecode($_GET['parm']); ?>[/code] Ronald  8)
  22. Have a look at [url=http://www.dhtmlgoodies.com/index.html?page=ajax]http://www.dhtmlgoodies.com/index.html?page=ajax[/url]. It is full of simple Ajax samples, with and without MySQL usage. Ronald  8)
  23. Use the newline char "\n" as the line break. Don't forget to put it between DOUBLE QUOTES. Ronald  8)
  24. Remove the single quote from this line [code] </tr>'";[/code] Ronald  8)
×
×
  • 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.