PHP - Simple Image Slideshow Not Working In Php
Hi, I'm trying to make a simple slideshow with forward and back buttons that change the image inside a div in php. When I press the "further" button, it jumps from index[0] to index[1] and never shows the first image. Then when I click more it doesn't go forward. When I click back, it goes back to a black screen div. Any help getting this to work is GREATLY appreciated because I've been trying for 2 days with tutorials and can't get it. Thanks. Derek
Here are the php parts that are relevant, my page was too large and confusing to include. first, the $background array where I store my images. Code: [Select] $background = array ( "<img src='sundragon_environments/ocean/ocean1_FRAME.jpg'/>", "<img src='sundragon_environments/ocean/ocean1_FRAME2.jpg'/>" ); then the code to move the images forward and backwards if the buttons are pressed. Code: [Select] if(!empty($_POST['further'])) { $currentBackground=next($background); } elseif(!empty($_POST['back'])) { $currentBackground=prev($background); } and now to echo out the images inside the div. Code: [Select] <div id="background"><?php echo $currentBackground;?></div> Similar TutorialsI was told that you guys could probably help me with this, so heres my situation. I use this program called Activeworlds, and me and my buddies are makeing a "tv show" if you will within the program. To do so, you take screenshots, save the screenshots, and add the image files into a directory on your domain. You need a .php script to present them as a slideshow. Now the problem is, ive searched for scripts already made from other sites, but the thing is, they are all fancy slideshow viewers, meaning they come with control buttons to cycle through the pictures and all kinds of other banners and flashy looking things. The only script im needing, is a simple script that will display and cycle through the raw images, and nothing else, within the web browser, in a slideshow format. Id also like to have a value I can edit that will change how fast the pictures cycle through, 15 seconds or so would be perfect however. If someone could refer me to this code or even make it for me, it would be soo appreciated. I know im probably asking for alot, but it would help me soo much. I wish I knew a little more about .php files to do it myself, or else I would. If you do link me to a script, please give me simple instructions on what to do with it lol because like I said, I dont know anything about the world of .php yet. Thank you all for your time. I have a page on my site which displays a picture that I have stored on my server. The loaction of that picture is stored in mysql. All the images are .jpg format. My question is, if I allow a user to upload 5 pictures instead of just 1, is there a simple script that would show each picture for about 2-3 seconds, the go to the next? Basically like an auto slideshow. Each picture has an ID that associates with the name of the category, so I could just call that ID and have the slideshow only show those pictures. So I'm just wondering about the slideshow script. I am running PHP Version 5.3.1. The following Code does not write to my database. It is code that I took from the PHP Pocket Reference from O'Reilly but it does not work... What's wrong with this code? Thanks in advance. Guy <?php if($vote && !$already_voted) SetCookie('already_voted',1); ?> <html> <head> <title>Name the Baby</title> </head> <h3>Name the Baby</h3> <form action="baby.php" method="POST"> <p>Suggestion: <input type="text" name="new_name"/> </p> <input type="submit" value="Submit idea and/or vote"/> <?php mysql_pconnect("localhost","root","password"); $db = "babynames"; $table = "baby_names"; if($new_name) { if(!mysql_db_query($db, "insert into $table values ('$new_name',0)")) { echo mysql_errno().': '. mysql_error()."<br />\n"; } } if($vote && $already_voted) { echo '<p><b>Hey, you voted already '; echo "Vote ignored.</b></p>\n"; } else if($vote) { if(!mysql_db_query($db, "update $table set votes=votes+1 where name='$vote'")) { echo mysql_errno().': '. mysql_error()."<br />\n"; } } $result=mysql_db_query($db,"select sum(votes) as sum from $table"); if($result) { $sum = (int) mysql_result($result,0,"sum"); mysql_free_result($result); } $result=mysql_db_query($db, "select * from $table order by votes DESC"); echo <<<EOD <table border="0"><tr><th>Vote</th> <th>Idea</th><th colspan="2">Votes</th></tr> EOD; while($row=mysql_fetch_row($result)) { echo <<<FOO <tr><td align="center"> <input type="radio" name="vote" value="$row[0]"></td> <td>$row[0]</td> <td align="right">$row[1]</td> <td> FOO; if ($sum && (int)$row[1]) { $per = (int)(100 * $row[1]/$sum); echo '<img src="bline.gif" height=12 '; echo "width=$per> $per %</td>"; } echo "</tr>\n"; } echo "</table>\n"; mysql_free_result($result); ?> <input type="submit" value="Submit idea and/or vote" /> <input type="reset" /> </form> </body></html> Hi, I have a php form that I use to try to get matching data from the database that I put into the form. So if I enter date of birth 9-4-80 and first name Dave and lastname Smith. When I submit it the code should pull all of the matching terms out of the database and display. Now I get the following error when I submit the form. Query: Resource id #2 Failed with 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 'Resource id #2' at line 1 any help Greatly appreciated. thank you! here is the code Code: [Select] <?php ini_set ("display_errors", "1"); error_reporting(E_ALL); $host = " "; $database = " "; $username = " "; $password = " "; $tbl_name = "users"; $conn = mysql_connect($host, $username, $password) or die("Could not connect: " . mysql_error()); if($conn) { mysql_select_db($database); echo "connected to database!!"; } else { echo "failed to select database"; } //include('bouncer.php'); //$currentUser = $_SESSION['myusername']; if(isset($_POST['submit'])) { $first = mysql_real_escape_string( $_POST['first']); $last = mysql_real_escape_string( $_POST['last']); $dob = mysql_real_escape_string( $_POST['dob']); //THE SEARCH FUNCTION $sql = mysql_query ( "SELECT * FROM users WHERE firstname LIKE '%$first%' OR lastname LIKE '%$last%' OR dob LIKE '%$dob%' ") or die(mysql_error()); $result = mysql_query($sql) or die( "<br>Query: $sql<br>Failed with error: " . mysql_error() ); if (!$result) { echo "Could not successfully run query ($sql) from DB: " . mysql_error(); exit; } if (mysql_num_rows($result) == 0) { echo "No rows found, nothing to print so am exiting"; exit; } while ($row = mysql_fetch_assoc($result)) { echo $row["firstname"]; echo $row["lastname"]; echo $row["dob"]; } }//if(isset($_POST['submit'])) ?> <html> <body> <form action="login_success8.php" method="post"> <p> <input type="text" name="first" size="20" /> First name<br /> <input type="text" name="last" size="20" /> Last name<br /> <input name="dob" type="text" size="20" id="dob" /> Date of Birth<br /> <input type="submit" name="submit" value="Search" /> <input type="reset" value="Reset fields" /> </p> </form> </body> </html> Hey all,
This code was given to me by my client who swears it works, yet I can't seem to get it to function. <?php $now = time(); // or your date as well $your_date = strtotime("2016-06-01"); $datediff = $now - $your_date; $referrals = number_format(162250 + (floor($datediff/(60*60*24)) * 527) + (87920 + (floor($datediff/(60*60*24)) * 45))); ?> //javascript: <script> //vars from template var referrals = "<?php echo $referrals;?>"; var currentdate = new Date(); jQuery("document").ready(function() { jQuery ("#sp-menu > div > nav > ul > li:nth-child(1) > a").html("Home"); jQuery(".referrals").html(referrals); jQuery(".current_date").html((currentdate.getMonth()+1) + "/" + currentdate.getDate() + "/" + currentdate.getFullYear()); jQuery(window).on("scroll", function() { var scrollPos = jQuery(window).scrollTop(); if (scrollPos <= 0) { jQuery(".counter").fadeIn(); jQuery(".sec-nav").fadeIn(); } else { jQuery(".counter").fadeOut(); jQuery(".sec-nav").fadeOut(); } }); }); </script>
I'm trying my first PHP code :
<!DOCTYPE html>
<?php
</body>
Result : nothing, just a blank screen ... Am I missing something ?
Regards, Martin The following mysql query is not returning rows like I expect it to. '$update_field' is a variable, matching an actual field name in table 'users'. 'user_task[1]' is an integer value. What am I missing here? Code: [Select] $query_update_user = "UPDATE users SET ".$update_field." = 'Y' WHERE user_no = '".$user_task[1]."'"; I've got to be missing something pretty basic here.. considering the query is pretty basic. I'm trying to figure out how to pull a query as an array so I can compare it against another array (array_diff) I'm doing a mysql_fetch_array, and I'm getting an error ( mysql_fetch_array(): supplied argument is not a valid MySQL result resource): Quote $checker = "SELECT ID FROM edible_uses"; $result2 = mysql_fetch_array($checker) or die(mysql_error()); //echoing to see if I'm getting what I need. echo $row['ID']; I've done a mysql_query and I get results. The table name and all that is correct. I'm stumped. This seems like a pretty simple query? I tried mysql_fetch_assoc as well. Same result? I tried it with an extra set of parenthesis around it. nope. Hi, I am new to php, and I have run into a problem. The tutorial I am using has provided me with this exact code. But it does not work for me. Its very simple. Here is the HTML page: Code: [Select] <body> <FORM ACTION="welcome.php" METHOD=POST> First Name: <INPUT TYPE=TEXT NAME="name"> <INPUT TYPE=SUBMIT VALUE="GO"> </FORM> </body> And here is the php page: <body> <?php echo( "Welcome to our Web site, $name!" ); ?> </body> You can see the problem live at <http://www.freewaycreative.com/test> (dont mind the digits below) The name just does not show. Anyone know why? Thanks! Not really sure what to ask because I don't know what the problem is. Maybe just need a fresh set of eyes to find out whats wrong. I am trying selecting content from a database table but its not working. I am not getting any errors just a blank screen where the content should be displayed. html Code: [Select] <table> <tbody> <tr> <th>Topic</th> <th>Name</th> <th>Date</th> </tr> <?php include 'server/forum.php'; ?> </tbody> </table> php Code: [Select] <?php require_once('load_data.php'); $con = mysql_connect($db_host, $db_user, $db_pwd); if (!$con) { die('Could not connect to database: ' . mysql_error()); } $dbcon = mysql_select_db($database); if (!$dbcon) { die('Could not select database: ' . mysql_error()); } $sql = "SELECT * FROM $table ORDER BY id"; $result = mysql_query($sql) or die("Error ". mysql_error(). " with query ". $sql); if (!$result) { die("Query to show fields from table failed:".mysql_error()); } $row = mysql_fetch_array($result) while($row) { echo '<tr>'; echo '<td class="forumtd"><b>'; echo '<a href="topic.php?id='.$row['id'].'">'.stripslashes(htmlspecialchars($row['topic'])).'</a>'; echo "</b></td>"; echo '<td class="forumtd"><em>'; echo stripslashes(htmlspecialchars($row['name'])); echo "</em></td>"; echo '<td class="forumtd">'; echo date("l M dS, Y", $row['date']); echo "</td>"; echo "</tr>"; } mysql_close($con); ?> Hello. i am writing an API for lua... that sends POST requests to a php script. this php script is malfunctioning. below is the code and error. well I lowered my standards massively. LOL. I decided to google, "php upload and display image", instead of "php gallery". Here is the error I get Warning: copy(/images/sheila.jpg) [function.copy]: failed to open stream: No such file or directory in /hermes/bosweb/web173/b1739/sl.brendansite1/public_html/ealike2/smallgallery/smallgallery.php on line 59 and here is the script that I mostly understand. I thought it was the ..images/, but now I don't know what it is. any help greatly appreciated. thank you. below is the code for the page. Code: [Select] <!-- Start PHP Code For Image Upload --> <?php //define a maxim size for the uploaded images in Kb define ("MAX_SIZE","5060"); //This function reads the extension of the file. It is used to determine if the file is an image by checking the extension. function getExtension($str) { $i = strrpos($str,"."); if (!$i) { return ""; } $l = strlen($str) - $i; $ext = substr($str,$i+1,$l); return $ext; } //This variable is used as a flag. The value is initialized with 0 (meaning no error found) //and it will be changed to 1 if an errro occures. //If the error occures the file will not be uploaded. $errors=0; //checks if the form has been submitted if(isset($_POST['Submit'])) { //reads the name of the file the user submitted for uploading $image=$_FILES['image']['name']; //if it is not empty if ($image) { //get the original name of the file from the clients machine $filename = stripslashes($_FILES['image']['name']); //get the extension of the file in a lower case format $extension = getExtension($filename); $extension = strtolower($extension); //if it is not a known extension, we will suppose it is an error and will not upload the file, //otherwise we will do more tests if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") && ($extension != "gif")) { //print error message echo '<h2>Unknown extension!</h2>'; $errors=1; } else { //get the size of the image in bytes //$_FILES['image']['tmp_name'] is the temporary filename of the file //in which the uploaded file was stored on the server $size=filesize($_FILES['image']['tmp_name']); //compare the size with the maxim size we defined and print error if bigger if ($size > MAX_SIZE*1024) { echo '<h2>You have exceeded the file size limit! Please reduce the image size to 100 Kb or less!</h2>'; $errors=1; } //we will give an unique name, for example the time in unix time format $image_name=$filename; //the new name will be containing the full path where will be stored (images folder) $newname="../images/".$image_name; //we verify if the image has been uploaded, and print error instead $copied = copy($_FILES['image']['tmp_name'], $newname); if (!$copied) { echo '<h2>Copy unsuccessful!</h2>'; $errors=1; }}}} //If no errors registred, print the success message if(isset($_POST['Submit']) && !$errors) { echo "<h2>File Uploaded Successfully!</h2><br />"; echo "<img src='http://ealike.com/images/<?php echo $image_name; ?> />"; } ?> <!-- End PHP Code For Image Upload --> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <!-- Start Image Upload Form --> <form name="newad" method="post" enctype="multipart/form-data" action=""> <input type="file" name="image"> <input name="Submit" type="submit" value="Upload image"> </form> <!-- End Image Upload Form --> </body> </html> I am trying to use JSONReader (along with PHP & XPATH) to parse a very large JSON file, then display search results. A stream parser (such as JSONREader) is recommended over JSON_decode when parsing large files. This simple code below is not displaying any results (in the echo statements). Any advice is greatly appreciated. Hi, I am performing some whois query using phpwois. http://www.phpwhois.org/ So after doing its object output i.e. Code: [Select] $whois = new Whois(); $result = $whois->Lookup($domain); $winfo = ''; $utils = new utils; $winfo = $utils->showHTML($result); , I am getting following data for for phpfreaks.com> Code: [Select] regrinfo->Array domain->Array name->phpfreaks.com nserver->Array ns1.serverpowered.net->204.13.168.4 ns2.serverpowered.net->216.12.222.4 ns3.serverpowered.net->66.97.171.74 ns4.serverpowered.net->66.97.171.254 status->Locked changed->2011-08-29 created->2001-10-11 expires->2016-10-11 registered->yes owner->Array name->Web Freaks address->Array 0->Contact Administrative () admin->Array email->domains@thewebfreaks.com name->Contact Administrative phone->4072751117 fax->+1.4072757706 address->Array 0->Web Freaks 4->3700 Commerce Blvd 5->Suite 154 6->Kissimmee, FL 34741 7->US tech->Array email->domains@thewebfreaks.com name->Contact Administrative phone->4072751117 fax->+1.4072757706 address->Array 0->Web Freaks 4->3700 Commerce Blvd 5->Suite 154 6->Kissimmee, FL 34741 7->US regyinfo->Array registrar->ENOM, INC. referrer->http://www.enom.com servers->Array 0->Array server->com.whois-servers.net args->domain =phpfreaks.com port->43 1->Array server->whois.enom.com args->phpfreaks.com port->43 type->domain Now I want to show Domain registrar (Enom, INC.) So I did following Code: [Select] echo $winfo['regyinfo']; Now above code shows following >> Code: [Select] registrar->ENOM, INC. referrer->http://www.enom.com servers->Array 0->Array server->com.whois-servers.net args->domain =phpfreaks.com port->43 1->Array server->whois.enom.com args->phpfreaks.com port->43 type->domain To obtain I mean to show ENOM, INC, I used following > Code: [Select] echo $winfo['regyinfo']['registrar']; But it gave error, so I used following >> Code: [Select] $temp = $winfo['regyinfo']; echo $temp['registrar']; But it give output as follows : < I dont know what wrong I am doing ? If it is showing regyinfo, then it should also show registrar. Thanks I have a form on my website which actions login.php. The login.php code is below: <?php include('includes/classes.php.inc'); session_start(); $link = new BaseClass(); $data = $link->query("SELECT * FROM logins"); $pass_accepted = false; if($_REQUEST['username'] && $_REQUEST['password']){ $username = $_REQUEST['username']; $password = $_REQUEST['password']; while($row = mysql_fetch_array($data)){ if(($row['username']==$useranme)&&($row['password']==$password){ echo 'Password correct!'; $_SESSION['loggedin']=true; $pass_accepted = true; } } } else { echo 'You did not enter a username or password!'; } if(!$pass_accepted){ echo 'Your password is incorrect'; } echo '<br>Please <a href="index.php">click here</a> to return to page'; ?> I have checked that my references are all correct however even when I enter the correct password it returns saying the password is incorrect. Any idea on why this could be? I am happy to answer any follow up questions. Regards The code.... very simple: $punc_body = explode(". ", $body); foreach ($punc_body as $k => $v) { $v = ucfirst($v); echo $v . "<br>"; // this is only here for testing purposes. } $body = implode(". ", $punc_body); Why doesn't this work? I threw in the echo $v in which it shows that it is doing everything properly, however when I implode the array everything that was capitalized is reverted back to lower-case. Can someone tell me whats wrong or what I'm missing here please. <?php session_start(); if(!isset($_SESSION['User'] )) header('Location : error.php'); ?> im not being redirected even when the $_SESSION['User'] is not set neither does it display any error message other than a white blank space. Please help me som1 as how I can make this to work or suggest any other altenatives so as to get it redirected as i dont want anonymous users to access some contents unles he logs in as members. Thanx Hi, I am learning PHP now, so pardon my silly question which I am not able to resolve from a week. I have created a simple web form where in I display the values entered by a user. <form action ="reply.php" id="myForm" method="post" > Name: <input type="text" name="name" size="25" maxlength="50" /> <br> </br> Description: <textarea name="editor1"> </textarea> <input type="submit" value="Submit" /> </form> and reply.php contains: <?php echo "In reply page"; foreach($_POST as $field => $value) { echo "$field = $value"; } ?> When I click on the submit button, I just get a blank page without any values from the form. Can anyone please let me know what am I missing? Set up: I am using Netbeans with PHP bundle added on to it. When i run only a simple php proj it displays that page in localhost/nameofproj, but when I run a php file along with a jsp file, it runs in localhost:8080/nameofproj. Is this the reason(localhost:8080 instead of just localhost ) for showing a blank page, not even a simple echo stmt, when i click on submit? I even re installed netbeans, still no luck. Thanks in advance. Hi, Im trying to pull an email from an url, and then echo the email as value into a email form-- under the "from" heading. The echo is not working i get blanks. here is the code: <?php $thisurl='$_SERVER['REQUEST_URI']'; $thepart = explode('/', $thisurl); $themail='$thepart[2]'; ?> <form method="post" action="sendit.php"> To: <br><input type="text" name="to" size="44" value="<?php for($i=1; $i<=$lines; $i=$i+1) { $names[$i] = str_replace("<br>", "", $names[$i]); $names[$i] = str_replace("\n", "", $names[$i]); echo $names[$i].';'; } ?>"><br> From: <br><input type="text" name="email" size="44" value="<?php echo '$themail'; ?>" readonly><br> Subject: <br><input type="text" name="subject" size="44" /><br><br> |