Jump to content

g1c9

Members
  • Posts

    11
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

g1c9's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hey, I am trying to display html between php code brackets if and only if a variable is set. For example: [code] <?php if ($some_var == 1) { echo(' ?> if some_var is equal to 1 then this will display, otherwise it wont! <?php '); } ?> [/code] Is this even possible? Please help me achieve this! Thanks in advance, Cameron
  2. That checks if it is a bot, correct? Does this work well for most SE bots? (eg: google, yahoo, msn) Any browsers this may cuase a problem for?
  3. Hey, I am trying to take the user agent and determine weather it is a browser or a bot on my site with PHP and the user agent. I am doing this by searching the user agent for common browsers/renderers. Here is the code I have so far: [code]     $agent = getenv("HTTP_USER_AGENT");     echo '<b>USER AGENT:</b> '.$agent.'<br><br>';     $x = 0;     $hide = array('Mozilla','MSIE','Opera','Lynx','WebTV','MCSA','Mosaic');     foreach ($hide as $find) {         if (strpos($agent, $find) === false) {             $is_bot[$x] = true;             }             echo $find.': '.$is_bot[$x].'<br>';             $x++;         }     $is_bot = false; [/code] I wish I could tell you all the problem so you could fix it, but I don't know the problem! The code above outputs nothing for the first one, (mozilla), and 1's for everything after that! Please help me debug this! Thanks in advance, Cameron
  4. Ok, I need your feedback on how to go about this. (Kind of like a puzzle, but this is for something practical.) This is basically what I want. Lets say I have 5 pages, and they all have a variable. See below. page | variable value ------------------------ 1 | APPLE 2 | COOKIE 3 | BANANA 4 | MONKEY 5 | TREE Now on each of my 5 pages, I want to display a word from one of the 4 other pages. Each page's word needs to be displayed as many times as that page has displayed all the other page's word. Each page displays a word when it loads. So basically, these words have a 1:1 display rate. (Everytime one word's page displays another page's word, another page will display its word.) The idea i have thus far is this: make a plain text file and put assign a key ID to each one of the items i listed above. On each page's load the file will be opened and the key will be read from the file, matched up in a DB with it's noun from the list, and then displayed. Then the noun from the page that just did all that will open up the text file and write its noun's key to the file. Wash, rinse, and repeat. However, I think that will get very,very slow becuase I plan on having many,many words. How do you suggest I go about this?
  5. THANK YOU!!! It finally works, and I'll make sure to PM you when the whole project is up and running. Also, I didn't mean to ignore your suggestion, I'm just not sure what [!--fonto:Lucida Console--][span style=\"font-family:Lucida Console\"][!--/fonto--]explicitly[!--fontc--][/span][!--/fontc--] means.
  6. I removed the unique key, and then using this code, tried again. $email = $_POST["email"]; echo 'email:'.$email.'<br>'; $link = md5($email); include("dbinfo.inc.php"); mysql_connect(localhost,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $query = "INSERT INTO tests VALUES ($email,$link)"; $result = mysql_query($query) or die ("ERROR: ".mysql_error()." with query: $sql"); echo $result; mysql_close(); I submitted the form email as cameron.garvie@gmail.com email:Cameron.garvie@gmail.com ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '@gmail.com,0136542e3041addfa391312618e87388)' at line 1 with query: Relevant server info. PHP version 4.3.11 MySQL version 4.1.13-standard
  7. Ok, so now my code is looking like this: $email = $_POST["email"]; echo 'email:'.$email.'<br>'; $link = md5($email); include("dbinfo.inc.php"); mysql_connect(localhost,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $query = "INSERT INTO tests VALUES ('cameron.garvie@gmail.com','camerons')"; $result = mysql_query($query) or die ("ERROR: ".mysql_error()." with query: $sql"); echo $result; mysql_close(); And when run, it spits out this: email:dasd1234asdasd@gmail.com ERROR: Duplicate entry 'cameron.garvie@gmail.com' for key 1 with query: So i check my DB, and it spits out this as the total: email | link ------------- email | link cameron.garvie@gmail.com | camerons Sorry, I'm new to all of this, whats wrong?
  8. $query = "INSERT INTO tests VALUES ('cameron.garvie@gmail.com','camerons')"; if (mysql_query($query)) { echo 'inserted'; } else { echo 'nope'; } I ran that code, (values hardcoded), and it returned 'nope'. Why is taht? tests is a table = and it has 2 string columns, email and link.
  9. Hey, I ran this code after submitting a form but for some reason I used phpmyadmin and there were no rows? $email = $_POST['email']; echo $email; $link = md5($email); include("dbinfo.inc.php"); mysql_connect(localhost,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $query = "INSERT INTO tests VALUES ($email,$link)"; mysql_query($query); mysql_close(); Is the problem the PHP code or the form? Here is the form. <form action="signup.php" method="POST"> <input type="text" name="email" size="40"><br><br> <input type="submit" value="Start tricking your friends!"> </form> I don't know what is wrong... EDIT: I have deduced that it is the form. But whats wrong with the form?
×
×
  • 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.