Jump to content

11Tami

Members
  • Posts

    329
  • Joined

  • Last visited

    Never

Everything posted by 11Tami

  1. Thanks a lot you guys, pdkv you lost me that time. The only $get I see is at the end, the arrays are named something else aren't they? Please let me know, thank you very much.
  2. Thanks both of you. Priti, what does the 1 do here? I dont know how to try it. I also tried these, this returns the file file1.txt on every page load correctly and never shows the text "test1". <?php $one[1] = "<span style='color: rgb(70,0,0)'>test1</span>"; $one[2] = "file1.txt"; $two1 = preg_grep('/(?:<span)/', $one); $two2 = preg_grep('/(?:<span)/', $one, PREG_GREP_INVERT); $rand1 = $two1[array_rand($two1)]; $rand2 = $two2[array_rand($two2)]; $file = file_get_contents($rand2); $get = $rand1 + $file; echo $get; ?> .....This only brings back the word "Array" on every page load and nothing else. Is there anyway I can grab onto both? Please let me know, thank you very much. <?php $one[1] = "<span style='color: rgb(70,0,0)'>test1</span>"; $one[2] = "file1.txt"; $two1 = preg_grep('/(?:<span)/', $one); $two2 = preg_grep('/(?:<span)/', $one, PREG_GREP_INVERT); $rand1 = $two1[array_rand($two1)]; $rand2 = $two2[array_rand($two2)]; $file = file_get_contents($rand2); $get = array_merge($rand1,$file); echo $get; ?>
  3. Hello, how would I pick an item from these 2 fields randomly, instead of one at a time? For example this picks an item randomly from both $one1 $one2 separately. How can I choose randomly from both of them instead? So that I only have one result at the end instead of 2? Please let me know, thank you very much. <?php $one= "<span style='color: rgb(70,0,0)'>test1</span>"; $one[3] = "file1.txt"; $one1 = preg_grep('/(?:<span)/', $one); $one2 = preg_grep('/(?:<span)/', $one, PREG_GREP_INVERT); $get1 = $one1[array_rand($one1)]; $get2 = $one2[array_rand($one2)]; $get3 = file_get_contents($get2); echo $get1; echo $get3; ?>
  4. For instance I tried adding this at the bottom as well like those right above it. Doesn't work. $get1 = $title2[$nbr2]; $get2 = $img2[$nbr2];
  5. Sorry about that everything froze, I couldn't finish my post. I have what I just listed above and I can't get it to show whats in $title2 and $img2 arrays. Everything I try doesn't work. Please let me know how to fix this. Thank you very much.
  6. Sorry for the numbers. Ok thanks a lot, its almost there now. Its showing whats in array title1 and img1 and matching them now but its not showing the rest. I have this. <? php $title1[1] = "title1"; $title1[2] = "title2"; $title2[3] = "title3"; $title2[4] = "title4"; $img1[1] = "http://upload.wikimedia.org/wikipedia/commons/thumb/9/9f/BahnhofBludenz.JPG/120px-BahnhofBludenz.JPG"; $img1[2] = "http://upload.wikimedia.org/wikipedia/commons/thumb/3/3c/Korean_stew-Budae_jjigae-01.jpg/120px-Korean_stew-Budae_jjigae-01.jpg"; $img2[3] = "http://upload.wikimedia.org/wikipedia/commons/thumb/8/82/Basilica_Cistern%2C_Constantinople.jpg/120px-Basilica_Cistern%2C_Constantinople.jpg"; $img2[4] = "http://upload.wikimedia.org/wikipedia/commons/thumb/c/c4/A330-200F.jpg/120px-A330-200F.jpg"; if(isset($_COOKIE["array"]) && $_COOKIE["array"]=="two"){ setcookie("array", "one", time()+60*60*24*180); $nbr1 = mt_rand(1, count($title2)); $nbr2 = mt_rand(1, count($img2)); }else{ setcookie("array", "two", time()+60*60*24*180); $nbr1 = mt_rand(1, count($title1)); $nbr2 = mt_rand(3, count($img1)); } $get1 = $title1[$nbr1]; $get2 = $img1[$nbr1]; echo "<img title='$get1' src='$get2' border='0'>"; ?>
  7. Hello, this pulls an image with a title on every next page load. Problem is when it pulls image one I need it to also pull "title 1" and when it pulls image 3 I need it to pull "title 3" right now its not doing that. Right now its sticking whatever title it wants in with the images. How can I get to match the arrays while its also pulling something randomly? Please let me know, thank you very much. <?php $title1[1] = "title1"; $title1[2] = "title2"; $title2[3] = "title3"; $title2[3] = "title3"; $img1[1] = "http://upload.wikimedia.org/wikipedia/commons/thumb/9/9f/BahnhofBludenz.JPG/120px-BahnhofBludenz.JPG"; $img1[2] = "http://upload.wikimedia.org/wikipedia/commons/thumb/3/3c/Korean_stew-Budae_jjigae-01.jpg/120px-Korean_stew-Budae_jjigae-01.jpg"; $img2[3] = "http://upload.wikimedia.org/wikipedia/commons/thumb/8/82/Basilica_Cistern%2C_Constantinople.jpg/120px-Basilica_Cistern%2C_Constantinople.jpg"; $img2[4] = "http://upload.wikimedia.org/wikipedia/commons/thumb/c/c4/A330-200F.jpg/120px-A330-200F.jpg"; if(isset($_COOKIE["array"]) && $_COOKIE["array"]=="two"){ setcookie("array", "one", time()+60*60*24*180); $get2 = $title2[array_rand($title2)]; $get3 = $img2[array_rand($image2)]; }else{ setcookie("array", "two", time()+60*60*24*180); $get2 = $title1[array_rand($title1)]; $get3 = $img1[array_rand($image1)]; } echo "<img title='$get2' src='$get3' border='0'>"; ?>
  8. Hello, how can I include two PHP variables in an image src, depending on which variable I will be using at the time? For example: <?php $image[1] = "http://store.officeworld.com/ProductImages/united/standard/MOW36113_1_1.JPG"; $image[2] = "https://store.officeworld.com/productimages/united/thumbnails/HAM122549_1_1_100.jpg"; $image[4] = "https://store.officeworld.com/productimages/united/thumbnails/A0001856.JPG"; $image[5] = "https://store.officeworld.com/productimages/united/thumbnails/HEWQ1396A_1_1_100.jpg"; $get1 = rand(1,2); $get2 = rand(3,4); echo "<img src='$image[$get1($get2)]' >"; ?> This following part from the above script I need help with: echo "<img src='$image[$get1($get2)]' >"; Sometimes I will only be using $get1 from the array, and other times I will only be using $get2 from the array, depending on what a database inserts into the image source. How can I have the src hold both $get1 and $get2 variables at the same time? The way I have it above says it cannot hold both. Please let me know, thank you very much.
  9. This works fine alone but when it goes into a web page or is included into a web page from another page with a php include, it quits working. It gives header errors. It doesn't seem to like new cookies set near the echos, which is a problem because the echos need to go in the body of the page so people can see their results. Does anyone know how I can set the cookies without getting the page header errors? Please let me know, thank you very much. <?php $one = Array(); $one[1] = "test1"; $one[2] = "test2"; $two = Array(); $two[5] = "test5"; $two[6] = "test6"; if(isset($_COOKIE["array"]) && $_COOKIE["array"]=="two"){ setcookie("array", "one", time()+60*60*24*180); echo $two[array_rand($two)]; }else{ setcookie("array", "two", time()+60*60*24*180); echo $one[array_rand($one)]; } ?>
  10. You have been most helpful to me on this, I really appreciate it and will send you a special thank you. I'm trying this but the echo's still aren't appearing, anyone know why? Please let me know, thank you very much. <?php setcookie("a", $getone, time()+60*60*24*180); $one = Array(); $one[1] = "test1"; $one[2] = "test2"; $two = Array(); $two[1] = "test5"; $two[2] = "test6"; $getone = array_rand($one); $gettwo = array_rand($two); if(isset($_COOKIE['a'])){setcookie("b", $gettwo, time()+60*60*24*180); echo $two[$gettwo];} if(isset($_COOKIE['b'])){setcookie("a", $getone, time()+60*60*24*180); echo $one[$getone];} ?>
  11. How do I get the cookie to remember which array it pulled from the first page load so it knows it should pull from the other array on the next page load? There are only two arrays included. Please let me know, thank you very much. <?php setcookie("a", $get1, time()+60*60*24*180); setcookie("b", $get2, time()+60*60*24*180); $one = Array(); $one[1] = "test1"; $one[2] = "test2"; $two = Array(); $two[1] = "test5"; $two[2] = "test6"; $getone = array_rand($one); $gettwo = array_rand($two); if(isset($_COOKIE['a']) && $getone){ echo $two[$gettwo];} if(isset($_COOKIE['b']) && $gettwo){ echo $one[$getone];} ?>
  12. I'm bringing it back to basics first to get the first part working, then I'll try to get the second working after that so here's what I have. PHP Code: <? php $one = Array(); $one[1] = "test1"; $one[2] = "test2"; $one[3] = "test3"; $one[4] = "test4"; $get = array_rand($one); echo $get; ?> Instead of showing "test1" ect. its only showing 1,2,3, or 4. Anyone know why? Thanks a lot.
  13. Anyone know? I can add the cookie to it, I just need to set up the rest. Thanks.
  14. Thanks a lot, I need it so that if it picked from array one randomly the first time, next time it will pick from array two. How do I write that? Please let me know, thank you very much. <?php ini_set('error_reporting', 8191); ini_set('display_startup_errors', 1); ini_set('display_errors', 1); $one = Array(); $one[1] = "test"; $two = Array(); $two[1] = "test2"; $get = shuffle($one,$two); echo $get; ?>
  15. Thanks a lot for the help but I think I still need a cookie. Cause it needs to remember what it saw the time before until the next visit, not to forget soon after the browser closes. I just hadn't put the expiration in the first one yet. Unless someone can tell me why I'm wrong. Please keep all the ideas coming, I really need a fix, thank you very much.
  16. Hello, I'm trying to switch to different text on every next page load. So the text below, "something" on one page load and "something else" on another page load. But this isn't working. Can someone please help me fix this? Please let me know its appreciated, thank you very much. <?php $switching = (isset($_COOKIE['toggle3']) and $_COOKIE['toggle3'] == 1) ? 1 : -1; setcookie('toggle3', $switching, 0); switch($switching) { case 1: echo "Something"; break; case -1: echo "Something else"; $switching *= -1; } ?>
  17. I mean so that if you don't want people to add something to your database from your web pages. You can temporarily do something to mysql to keep any data from being inserted.
  18. Thank you. Does anyone know if mysql has some sort of button where you can keep entries temporarily from being added? Please let me know, thank you very much.
  19. Hello, is there an easy way to to stop entries to mysql? But also so the echo from the php still works on the page like it should when the form is submitted? Please let me know, thank you very much. Here's the basic setup: <?php if ($_POST['softwareemail']==""){ <form method='POST' action='<?php echo $_SERVER["PHP_SELF"]; ?> <input type='text' name='softwareemail' > <input type='submit' value='submit'> ?> <?php $con = mysql_connect("","",""); if (!$con) { die('Could not connect: ' . mysql_error()); }mysql_select_db("", $con); $email = $_POST['softwareemail'] ; $sql="INSERT INTO addsoftware (softwareemail) VALUES ('" . $_POST['softwareemail']. "')"; if (mysql_query($sql,$con)) {echo "data submitted";} ?>
  20. I don't know how to add the second parameter of the array to the image link further below url, location, etc., the cookie expiration I can do. Can someone help me with this last piece? Thank you very much. <?php $cookie="cookie expiration here" $image = Array(); $image[1]['location'] = "http://www.google.com"; $image[1]['URL'] = "http://www.website.com/1.jpg"' $image[1]['name'] = "http://www.yahoo.com"; $image[2]['location'] = "image title 1"; $image[2]['URL'] = "http://www.website.com/2.jpg"' $image[2]['name'] = "image title 2"; if (in_array(substr($image[$cookie], -3), array('jpg'))) $getimage = $image[$cookie]; ?> <?php echo "<a href=''[$cookie]"><img title='[$cookie]' src=''[$cookie]" border='0'></a>"; ?>
  21. Thanks a lot everybody you're tops!!! oi, pc nerd, I think thats it! But how do I use the name, url, location, in this following?? Please let me know, thank you very much. <?php echo "<a href='$link[$cookie]'><img title='$title[$cookie]' src='$getimage' border='0'></a>"; ?>
  22. Hello I'm stuck on and need help. Its going pretty well but where I'm at is below the line. My questions is, is there any way to make the arrays simpler? I studies php arrays but can't make sense of their examples. For instance with PHP can I put the array's together somehow from left to right instead from top to bottom? So instead of what I have below the line is it possible to do an array something like this? $image[1] = "http://www.website.com/image1.jpg"; $link[1] = "http://www.google.com"; $title[1] = "image title 1"; I still need the the lines in the array numbered. Please let me know if there is a way to list the numbered arrays from left to right instead of the way I have it below. Thank you very much. _______________________________________________ $cookie=cookie expiration code goes here. $image = Array(); $image[1] = "http://www.website.com/image1.jpg"; $image[2] = "http://www.website.com/image2.jpg"; $link = Array(); $link[1] = "http://www.google.com"; $link[2] = "http://www.yahoo.com"; $title = Array(); $title[1] = "image title 1"; $title[2] = "image title 2"; if (in_array(substr($image[$cookie], -3), array('jpg'))) $getimage = $image[$cookie]; ?> <?php echo "<a href='$link[$cookie]'><img title='$title[$cookie]' src='$getimage' border='0'></a>"; ?>
  23. I got it, return email was set up as a post instead of only an address, thanks.
  24. Yes its online, but doesn't work.
  25. Hello, I'm trying to send a simple select choice to an email. So whatever selection someone picks in the drop down box is sent to my email. I've read up on this thoroughly and nothing at all with this is being sent to my email. Can't figure out why. I even included an echo that if the mail function works to state it is working. If its not working to echo it isn't working. It echos its working just fine but nothing is still being sent to my email. Will someone please look at this and tell me what I am doing wrong? Thank you very much. <?php if (!isset($_POST['submit'])) { //the submit button has NOT been clicked so make the form ?> <form action="<?php $_SERVER['PHP_SELF'] ;?>" method="post" > <select name="pickone" > <option value="small">blue</option> <option value="medium">green</option> </select> <input type="submit" name="submit"> </form> <?php } //close if not submit not pushed if (isset($_POST['submit'])) { //Submit was clicked so send to the email $email = $_POST['support@website.com'] ; $pick = $_POST['pickone'] ; $mailto = 'support@website.com' ; $subject = 'Email Subject Selection Made' ; $headers = "From: <$email>\r\n"; $headers .= "Reply-To: ".preg_replace('/[\r\n]+/', ' ', $_POST['$email'])."\r\n"; $headers .= "X-Mailer: PHP/".phpversion(); $messageproper = "Pick Selected: $pick\n\n"; mail($mailto,$subject,$messageproper,$headers); if (mail) {echo "working";} else if (!mail) {echo "not working";} } ?>
×
×
  • 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.