Jump to content

scotmcc

Members
  • Posts

    58
  • Joined

  • Last visited

About scotmcc

  • Birthday 12/18/1976

Contact Methods

  • AIM
    scot_mcc
  • MSN
    scot_mcc@msn.com
  • Website URL
    http://www.theballyhoo.com
  • ICQ
    50834254
  • Yahoo
    scot_mcc

Profile Information

  • Gender
    Male
  • Location
    Lake Forest, CA

scotmcc's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Looks to me like you're probably getting a (bool) false back from these addresses, which will show up as nothing in HTML. Try this: <form method="post" action="<?php echo $PHP_SELF;?>"> <textarea name="new" cols="40" rows="10"> samplehost-1,127.0.0.1 samplehost-2,127.0.0.2 </textarea><br> <input type="submit" value="Add Servers"> </form> <?php if(isset($_POST['new'])) { $array = explode("\n",$_POST['new']); foreach ($array as $ni) { $test = explode(',', $ni); echo ip2long(trim($test[1]))."<br/>"; } } ?> I just threw a trim() around the item. I also changed your second variable to '$test' as it looked to me like you were overwriting your original $array with the second explode... but I didn't look at it long enough to be sure. Just make sure you're grabbing an IP address. You might think about using a regular expression... something like this: <form method="post" action="<?php echo $PHP_SELF;?>"> <textarea name="new" cols="40" rows="10"> samplehost-1,127.0.0.1 samplehost-2,127.0.0.2 samplehost-3,999.999.999.999</textarea><br> <input type="submit" value="Add Servers"> </form> <?php if(isset($_POST['new'])) { $RE = "/(??: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]?)/"; foreach (explode("\n",$_POST['new']) as $address) { $data = array(); if (preg_match($RE, $address, $data)) { var_dump($data); echo $address." = ".ip2long($data[0])."<br />"; } else { echo "Not a valid address!"; } } } ?>
  2. I have a few comments, but without setting up a database to test your code (which I am too tired to do at the moment), I am not sure if it solves your problem... your code with my comments: // I don't see any problem here.... and it seems to work fine. // it produces this: // SELECT * FROM xy_db WHERE clubname ='blah' (where blah is $data3) $resultF = sprintf("SELECT * FROM xy_db WHERE clubname ='%s'", mysql_real_escape_string($data3)); $resultFin = mysql_query($resultF); // Here I believe is a problem, you set "$resultFin" to the resource // data of the mysql query. However, when you go to look at the data, // you use the variable "$resultf" which is never defined in your code. // I assume this should be "$resultFin" if (mysql_num_rows ($resultf) > 0){ $register = "Retry."; echo($register); } else { $go =sprintf("INSERT INTO ab_db (surnamez, firstnamez) VALUES ('%s', '%s'", mysql_real_escape_string($data1), mysql_real_escape_string($data2)); $result = mysql_query($go); }
  3. I looked at your code and tested it on my page and it correctly identified a URL. Here is your code in my test page... <?php if (preg_match("/http/i",$_REQUEST['test'])) { echo "Entered a link!"; exit(); } else { echo "Not a link!"; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>form test</title> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1"> </head> <body> <form action="<?php echo $PHP_SELF;?>" method="POST"> <input type="text" name="test" id="test" /> <input type="submit" value="submit" /> </form> </body> </html> Is it possible that there is another branch of the code that is being executed and the code you wrote (that seems to work for me) is never being executed?
  4. It is possible that I've gone crazy, but the syntax looks a little busted to me: You wrote: <?php if (isset($_POST['synonymsearch'])) echo { $_POST ['synonymsearch']; } ?> I think it should be: <?php if (isset($_POST['synonymsearch'])) { echo $_POST ['synonymsearch']; } ?> What do you think?
  5. <?php if ($_REQUEST['test']=='post') { echo "The field did contain the text 'post'."; } else { echo "The field did not contain the text 'post'."; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>form test</title> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1"> </head> <body> <form action="<?php echo $PHP_SELF;?>" method="POST"> <input type="text" name="test" id="test" /> <input type="submit" value="submit" /> </form> </body> </html> Try playing around with this... It checks to see if something was submitted (which it sounds like what you are asking). Additionally, if you are asking specifically if something was posted from a variable called post, change the php code to look something like this: <?php if ($_REQUEST['test']=='post') { echo "The field did contain the text 'post'."; } else { echo "The field did not contain the text 'post'."; } ?>
  6. Use a regular expression... preg_match('/\d{3}/', 123) Or, do it in JavaScript... It is usually a good idea to validate the input on the page rather than make the user wait to have you reload the page just to tell the user that he or she needed to use a specific input. See: http://us.php.net/manual/en/function.preg-match.php
  7. mysql_real_escape_string See: http://us.php.net/manual/en/function.mysql-real-escape-string.php
  8. You need to use a regex format: <?php $entry = "1230999"; if (preg_match('/999$/', $entry)) { echo "You are a winner!!!"; } else { echo "Sorry, better luck next time."; } ?> See: http://us.php.net/manual/en/function.preg-match.php
  9. Try doing this: $name = (String)$stats1->player[0]["name"];
  10. That is an easy fix, though... Just make sure you allow them to search for any part of the string. Also, JavaScript (not Java ) is very simple to use. I'd imagine you could probably implement the JS solution in a few hours, even if you are not familiar with the language. foreach($letter in explode($user_name_entered)) { // See the % before and after the $letter. That will // search the entire string for a like string. $SQL = "SELECT [ field ] FROM [ table ] WHERE [ field ] LIKE '%".$letter."%'"; // get the result if (mysql_num_rows($result) < 10) { // return list; } }
  11. Well, one way to do something *like* that might be to get a list of distinct values (name, for instance) before the user even enters his data. Then, using JavaScript you could simply display a dropdown keyed from a text box that the user can type into, quickly eliminating the words in the dropdown that do not match a regex value... OR You could create a loop in PHP that loops over the results that match name one character at a time until the number of results are manageable... for instance: foreach($letter in explode($user_name_entered)) { $SQL = "SELECT [ field ] FROM [ table ] WHERE [ field ] LIKE '%".$letter."'"; // get the result if (mysql_num_rows($result) < 10) { // return list; } } A lot more processing for the second one...
  12. Well Sir, I think you need to be a little more specific if you'd like a real answer... However, based on what I guess that you're asking (keep in mind this is just a little pseudo-code): // ... I assume you have some input from the user, probably through $_REQUEST $keywords = explode(',', $user_input_keywords); /* You will probably want to do some validation * here on the list of keywords the user has entered. * Also, I imagine you'll need to do some formatting * for the MySQL query below. */ // ... I also assume you have a keyword section in your database. $query = "SELECT [ field ] FROM [ table ] where `keyword` in (" . implode(',', $keywords) .")"; // Then do some stuff with the data you get back. There are several informative posts for MySQL here: http://us.php.net/manual/en/book.mysql.php
  13. Try doing this: while(false !== ($rV = mysql_fetch_array($resultVoting)))
  14. Remove the if block and just set $site to the $_post variable.
×
×
  • 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.