PHP - After Script Executes It Still Continues To Load
The following code does what I want it to, but after it's done doing it, it won't stop loading.
I believe it is because of the while loops (while(1) { ... } and while($data = ...) { ... }). I need while($data = ...) to read the data from the fsockopen. Thanks in advance function ircConnect($server, $port, $channel, $nick, $pass, $name, $msg) { set_time_limit(15); //If we put set_time_limit(0), the page won't timeout and never stops loading (The script works, that I'm aware of) $fp = fsockopen($server, $port); if(!$fp) die($php_errormsg); if(empty($php_errormsg)) { $error = "None!"; } else { $error = $php_errormsg; } echo "<table border='1' bordercolor='#FFCC00' style='background-color:#FFFFCC' width='400' cellpadding='3' cellspacing='3'>"; echo "<tr><td>Server</td><td>Port</td><td>Channel</td><td>Nick</td><td>Password</td><td>Error</td></tr>"; echo "<tr><td>$server</td><td>$port</td><td>$channel</td><td>$nick</td><td>$pass</td><td>$error</td></tr>"; echo "</table>"; fputs($fp, "USER aBot testchan.org TestchanIRCBot :TheBot\n"); fputs($fp, "PASS $pass\n"); fputs($fp, "NICK $nick\n"); fputs($fp, "JOIN $channel\n"); fputs($fp, "PRIVMSG $channel :$msg, my name is $nick!\n"); while($data = fgets($fp, 128)) { $ex = explode(' ', $data); echo nl2br($data); flush(); if($ex[0] == "PING") fputs($fp, "PONG " . $ex[1] ."\n"); } } http://i.imgur.com/E6j79.jpg Similar TutorialsHi, I have a sql query that executes perfectly in phpMyAdmin but when applied to a PHP script returns nothing. It won't even start a "while" loop. Please review code snippits below. Submission Script calls function in Database Class: $result = $database->testReturnId($_POST['years'], $_POST['model']); while($row = mysql_fetch_array($result)) { $i = $i + 1; echo "ROW " . $i . " " . $row['auto_id'] . " " . $row['auto_year'] . " " . $row['auto_year_high'] . " " . $row['auto_make'] . " " . $row['auto_model'] . "<br />"; } Database Class Function: function testReturnId($year, $model){ global $form; $q = 'SELECT * FROM tbl_svc_auto WHERE auto_model = "$model" AND "$year" BETWEEN auto_year AND auto_year_high'; if(!mysql_query($q, $this->connection)){ return false; }else{ return $result = mysql_query($q, $this->connection); } } I have moved the query to the submission script and replaced the variables with actual data and it still will not work. I can take the same query with out the variables and input it into phpMyAdmin and it works great. On the submission script, I added a row number to the echo thinking that it would a least return the word "ROW" and it does not. I have tested each step of the execution of the query and have not returned any errors. I do not receive any errors at all even during execution. It just seems to refuse to run the "while" statement. I do not know where my problem is......Please help. Thank you in advance for any assitance you can offer. Joshua this Chinese bot or what ever managed to reinsert stuff into a contact form of mine he made adjustments from about half a year ago, now in a field where i get an INT a i got alkdnKJKHkk in mail but 2rand[0,1,1] in the db field also regarding regex for date formats i require only dd-mm-yyyy thats only numbers and 2 dashes thanks So I have 2 queries, that has the potential to return alot of data, foreach loops running. The first shows each group heading, and the foreach nested is calling another query specific to the group heading. The result currently is a lengthy delay in results showing. (Now this may/may not be the most ideal code practise in this instance however... short term solution discussion please). For Each State Read Each States Details from DB For Each State Listing Display Details Next Next Is there a command or other where I can say, Display HTML page as it stands while it continues to process the FOREACH loops? EG: For Each State Read Each States Details from DB For Each State Listing Display Details REFRESH HTML DISPLAYED Next Next Can someone help me I have been working on this problem for some time. I have coded my page to welcome, firstname. At first in my insert I had used the id I have not switched it to the username as id was including everyone of my test names in the welcome. It looks like the sessions are continuing as I am able to go to the private section of the pages. However I am not sure what I have to do to produce the welcome, firstname to go to all the pages and let me know it is allowing the one member to access the private sessions. Also when I use the login form it does not recognize the users. It is like the connection to the database dies i guess. here is my codes. <?php session_start(); ini_set ("display_errors", "1"); error_reporting(E_ALL); ?> <!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>Welcome</title> <style type="text/css"> .background {color: #B56AFF; } </style> </head> <body> <p> <?php /* Program: login.php * Desc: Displays the new member welcome page. Greets * member by name and gives a choice to enter * restricted section or go back to main page. */ if (isset($_SESSION['username'])) { // Set the users session ID include("Connections/connect_to_mysql.php"); //Formulate Query //This is the best way to perform an SQL query $query = mysql_query ("SELECT * FROM `Members` WHERE username={$_SESSION['username']}"); $result = mysql_query($query); $numrows = mysql_num_rows($query); //Check result //This shows the actual query sent to MySQL and the error. Useful for debugging. if(!$result){ $message = 'Invalid query:' . mysql_error() . "\n"; $message .= 'Whole query:' . $query; die($message); } //Use result //Attempting to print $result won't allow access to information in the resource //One of the mysql result functions must be used //See also mysql_result(), mysql_fetch_array(), mysql_fetch_row(), etc. if($numrows!=0){ while($row = mysql_fetch_assoc($query)); $dbusername = $row['username']; $dbpassword = $row['password']; //check to see if they match! if($username==$dbusername&&md5($password)==$dbpassword){ echo "Welcome, ".$_SESSION['firstname']. "!<br><a href='logout_test.php'>Logout</a>"; } } } ?> </p> <p> </p> <p>Your new Member accounts lets you enter the members only section of our web site. You'll find special discounts, a profile of matches, live advise from experts, and much more.</p> <p>Your new Member ID and password were emailed to you. Store them carefully for future use.</p> <div style="text-align: center"> <p style="margin-top: .5in; font-weight: bold"> Glad you could join us!</p> <form action="profile.php" method="post"> <input type="submit" value="Enter the Members Only Section"> </form> <form action="index.php" method="post"> <input type="submit" value="Go to Main Page"> </form> </div> </body> </html> <?php session_start(); ini_set ("display_errors", "1"); error_reporting(E_ALL); ?> <!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>Welcome</title> <style type="text/css"> .background {color: #B56AFF; } </style> </head> <body> <p> <?php /* Program: login.php * Desc: Displays the new member welcome page. Greets * member by name and gives a choice to enter * restricted section or go back to main page. */ if (isset($_SESSION['username'])) { // Set the users session ID include("Connections/connect_to_mysql.php"); //Formulate Query //This is the best way to perform an SQL query $query = mysql_query ("SELECT * FROM `Members` WHERE username={$_SESSION['username']}"); $result = mysql_query($query); $numrows = mysql_num_rows($query); //Check result //This shows the actual query sent to MySQL and the error. Useful for debugging. if(!$result){ $message = 'Invalid query:' . mysql_error() . "\n"; $message .= 'Whole query:' . $query; die($message); } //Use result //Attempting to print $result won't allow access to information in the resource //One of the mysql result functions must be used //See also mysql_result(), mysql_fetch_array(), mysql_fetch_row(), etc. if($numrows!=0){ while($row = mysql_fetch_assoc($query)); $dbusername = $row['username']; $dbpassword = $row['password']; //check to see if they match! if($username==$dbusername&&md5($password)==$dbpassword){ echo "Welcome, ".$_SESSION['firstname']. "!<br><a href='logout_test.php'>Logout</a>"; } } } ?> I am working on an page where I have a video playing in a div, using jwplayer. I have a form in another div below the player div that appears by changing the display:none property at a certain time, but this requires my users to scroll down to see it below the video div. I would prefer this form div to appear and the video div to disappear simultaneously, which is simple enough, but I need the audio from the video div to continue playing uninterrupted, then the divs would switch back after a period of time. I guess another option would be to have the form div appear and float over the video div, but I'm not sure how to do that. Any nifty suggestions? Hi, I am wanting to create a random fact script for a small website project. The idea is when the user loads a page a random fact will appear at the top ( I guess from an array of strings I will make?) Can anyone recommend the most efficient and easiest way to go about this please? hi everyone i've just finnished a lynda.com course and began coding my own site.. i want to be able to put the script it self in the database. Then from read and execute the script from content.php BUT i get this error Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in C:\wamp\www\content.php(35) : eval()'d code on line 1 Call Stack so far it's has been fairly easy to correct the errors, but this one i don't know how to handle.. can anyone give me a hint where I've mistaken The script i put in the database if (!isset($_GET['category'])) { $query = "SELECT * FROM links ORDER BY category ASC"; $result = mysql_query($query); echo "<table border=\"0\" width=\"100%\"> <tr> <td> <ul>"; while ($row = mysql_fetch_assoc($result)) { echo "<li><a href=\"links.php?content=links&category=" . $row['category'] . "\">" . $row['category'] . "</a></li>"; } echo "</ul> </td> </tr> </table>"; } if (isset($_GET['category'])) { $linkcat = $_GET['category']; $query = "SELECT * FROM links WHERE category='{$linkcat}' ORDER BY title ASC"; $result = mysql_query($query); while ($row = mysql_fetch_assoc($result)) { echo "<table border=\"0\" width=\"100%\" height=\"160\"> <tr> <td colspan=\"3\" align=\"center\" valign=\"top\"> <h1><a href=\"" . $row['address'] . "\">" . $row['title'] . "</a></h1> </td> </tr> <tr> <td colspan=\"3\" align=\"center\" valign=\"middle\"> <p>" . $row['description'] . "</p> </td> </tr> <tr> <td align=\"left\" valign=\"bottom\" style=\"float:right\"><a href=\"profile.php?username=" . $row['author'] . "\">" . $row['author'] . "</a></td> <td align=\"center\" valign=\"bottom\"><p>" . $row['votes'] . "</p></td> <td align=\"right\" valign=\"bottom\" style=\"margin-right:10;\"><p>" . $row['clicks'] . "</p></td> </tr> </table> <br /> <hr /> <br />"; } } content.php <?php require_once('includes/connection.php'); ?> <?php $content = $_GET['content']; $query = "SELECT * FROM pages WHERE page_name='{$content}'"; $result = mysql_query($query); if (!$result) { echo "Could not successfully run query from DB: " . mysql_error(); exit; } if (mysql_num_rows($result) == 0) { echo "No rows found, nothing to print so am exiting"; exit; } $row = mysql_fetch_assoc($result); $str = $row['content']; eval("\$str = \"$str\";"); echo $str; ?> Thank you in advance Dokter G Hello there, I have a script which uses the LOAD DATA LOCAL INFILE command see below: <?php //connect to your database mysql_connect("localhost", "xxx", "xxx"); //(host, username, password) //specify database mysql_select_db("xxx") or die("Unable to select database"); //select which database we're using // Build SQL Query $query = "LOAD DATA INFILE '/public_html/admin/files/test-jp-stock.csv' INTO TABLE 'jpaero_stocksearch' FIELDS TERMINATED BY ',' LINES TERMINATED BY '\r\n' IGNORE 1 LINES"; if(mysql_query($query)){ echo ">> New Stock Data has now been uploaded. Database is now live and searchable.";} else{ echo "Upload failed. Please contact support.";} ?> Initially I uploaded the csv file through phpmyadmin and everything worked fine - so I then used the SQL generated inside my script, changing the location to where the file actually is - however now nothing happens at all. Any ideas on whats gone wrong, gratefully received! Thanks, Hi I've been working on a site for 6 months and have used the header command to redirect loads and loads of times. But i just noticed some crazy behaviour today. Heres a test page: <?php include("includes/db_connect.php"); header('location:stores.php'); $sql = "insert into test (id) values (77)"; $result = mysql_query($sql); ?> when i hit this page, i get redirected to stores.php, but the sql gets executed! Is this supposed to be the behaviour? Have i completely missed the point of header(location:)?? Im baffled as i've used this before, but only now noticed this crazy behaviour! Good evening, I am currently doing a web application which requires pulling out of data from the database. I am still a novice in the programming industry, and is still seeking help from my colleagues and of course forum sites like phpdn. I have an existing code which my friend provided me. I have already done some modifications with the code. I have a problem though with the code, it executes database query upon loading of the page. I do understand how the code works, however, I am not able to modify the code to disallow the execution of query upon loading of page. Here is the code: <?PHP include("dbconnection.php"); $query = "SELECT * FROM records"; if(isset($_POST["btnSearch"])) { $query .= " WHERE last_name LIKE '%".$_POST["search"]."%' OR first_name LIKE '%".$_POST["search"]."%'OR territory LIKE '%".$_POST["search"]."%'OR job_title LIKE '%".$_POST["search"]."%'OR title LIKE '%".$_POST["search"]."%'OR employer LIKE '%".$_POST["search"]."%' " ; } $result = mysql_query($query, $connection) or die(mysql_error()); ?> I do know that this php code, the way it is written, is supposed to do that - to select data from my database (This code was provided by a friend). But my requirement for the project is actually to give it a search engine and display the information based from the search query. I have a search engine already together with the code, and it works pretty well. What I must do is to disallow the pulling of data from the first load, but just pull data if the search engine is used. Here's the whole code: <link href="add_client.css" rel="stylesheet" type="text/css"> <?PHP include("dbconnection.php"); $query = "SELECT * FROM records"; if(isset($_POST["btnSearch"])) { $query .= " WHERE last_name LIKE '%".$_POST["search"]."%' OR first_name LIKE '%".$_POST["search"]."%'OR territory LIKE '%".$_POST["search"]."%'OR job_title LIKE '%".$_POST["search"]."%'OR title LIKE '%".$_POST["search"]."%'OR employer LIKE '%".$_POST["search"]."%' " ; } $result = mysql_query($query, $connection) or die(mysql_error()); ?> <table width="760" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td><table width="760" border="0" cellpadding="0" cellspacing="0"> <tr> <td width="199" align="center" valign="top"><a href="login.html"><img src="asia.gif" alt="" width="152" height="58" border="0" /></a> <script type="text/javascript" src="menu.js"></script></td> <td width="176" align="right" valign="bottom"><a href="main.php"><img src="Home.jpg" width="104" height="20" border="0"/></a></td> <td width="130" align="right" valign="bottom"><img src="View.jpg" width="104" height="20" border="0"/></td> <td width="146" align="right" valign="bottom"><a href="add_client.php"><img src="Add.jpg" width="104" height="20" border="0"/></a></td> <td width="109" align="right" valign="bottom"> </td> </tr> </table></td> </tr> <tr> <td><table width="760" border="0" cellpadding="0" cellspacing="0"> <tr> <td width="200" height="3" bgcolor="#1B1C78"><img src="images/topspacerblue.gif" alt="" width="1" height="3" /></td> <td width="560" bgcolor="#0076CC"><img src="images/topspacerlblue.gif" alt="" width="1" height="3" /></td> </tr> </table></td> </tr> <tr> <td height="553" align="center" valign="top" bgcolor="#F3FAFE"><br /> <form name="form" action="view_client.php" method="post"> <table width="351" border="0"> <tr> <td width="137" align="left" valign="middle">SEARCH RECORD:</td> <td width="144" align="center" valign="middle"><input type="text" name="search" /></td> <td width="56" align="left" valign="middle"><input type="submit" name="btnSearch" value="Search" /></td> </tr> </table> <br /> <table width="680" border="0" cellpadding="3" cellspacing="1" bordercolor="38619E" > <tr> <th width="100" align="center" bgcolor="#E0E8F3">Territory</th> <th width="110" align="center" bgcolor="#E0E8F3">Employer</th> <th width="110" align="center" bgcolor="#E0E8F3">Job Title</th> <th width="50" align="center" bgcolor="#E0E8F3">Title</th> <th width="110" align="center" bgcolor="#E0E8F3">First Name</th> <th width="110" align="center" bgcolor="#E0E8F3">Last Name</th> <th width="70" align="center" valign="middle" bgcolor="#E0E8F3"> </th> </tr> <?php if($result) { for($i=0; $i<mysql_num_rows($result); $i++) { $id = trim(mysql_result($result, $i, "id")); $territory = trim(mysql_result($result, $i, "territory")); $employer = trim(mysql_result($result, $i, "employer")); $job_title = trim(mysql_result($result, $i, "job_title")); $title = trim(mysql_result($result, $i, "title")); $first_name = trim(mysql_result($result, $i, "first_name")); $last_name = trim(mysql_result($result, $i, "last_name")); echo "<tr>"; echo "<td>".$territory."</td>"; echo "<td>".$employer."</td>"; echo "<td>".$job_title."</td>"; echo "<td>".$title."</td>"; echo "<td>".$first_name."</td>"; echo "<td>".$last_name."</td>"; echo "<td><a href='admin_edit.php?id=".$id."'>edit</a> | <a href='admin_delete.php?id=".$id."'>del</a> </td>"; echo "</tr>"; } } ?> </table> <br /> </form> <p> </p></td> </tr> <tr> <td height="38"><table width="760" border="0" cellpadding="0" cellspacing="0"> <tr> <td width="200" height="35" align="center" bgcolor="#1B1C78" class=white><img src="images/topspacerblue.gif" alt="" width="1" height="3" /> <a href="disclaimer.html"><font color="#FFFFFF">Legal Disclaimer</font></a> </td> <td width="560" align="center" bgcolor="#0076CC" class=white><img src="images/topspacerlblue.gif" alt="" width="1" height="3" /> Copyright © 2006 - 2010 Limited. All rights reserved. </td> </tr> </table></td> </tr> </table> Immediate response is well appreciated. Thank you very much! Hi,
In reference to my first attached image, I have a form which displays two SELECT/drop-down fields (labeled "Store Name" and "Item Description".....and both of which pull-in values from two separate lookup/master tables, in addition to providing an additional option each for "NEW STORE" and "NEW ITEM").
Now, when first-run, and/or if "NEW STORE" and "NEW ITEM" are not selected from the drop-down's then the two fields in green ("New Store Name" and "New Item Name" are hidden, by means of the following code:
<div class="new-store-container" id="new-store-container" name="new-store-container" style="display:none;"> <div class="control-group"> <div class="other-store" id="new_store_name"> <?php echo standardInputField('New Store Name', 'new_store_name', '', $errors); ?> </div> </div> </div>Conversely, if "NEW STORE" and/or "NEW ITEM" are selected from the two drop-down's then one (or both) of the "New Name" fields are unhidden by means of the following two pieces of code, one PHP and the second JS: <select class="store-name" name="store_id" id="store_id" onclick="toggle_visibility('store_id','new-store-container')"> <?php echo $store_options; ?> <?php if($values['store_id'] == "OTH") { echo "<option value='OTH' selected> <<<--- NEW STORE --->>> </option>"; } else { echo '<OPTION VALUE="OTH"> <<<--- NEW STORE --->>> </OPTION>'; } ?> </select> function toggle_visibility(fieldName, containerName) { var e = document.getElementById(fieldName); var g = document.getElementById(containerName); if (e.value == 'OTH') { if(g.style.display == 'none') g.style.display = 'block'; else g.style.display = 'none'; } }All of that is working just fine. The problem I'm having is that when I click the "Create" button, after having left any one of the form fields blank, the two "New Name" fields are hidden again, which I don't want to happen i.e. I want them to remain visible (since the values of "store_id" and/or "item_id" are "OTH"), so that the user can enter values into one or both of them, without havng to click on the drop-down a second time in order to execute the "on-click" code. The second attached image shows how the fields are hidden, after clicking "Create". How can I achieve that? It would be greate if someone could cobble-up the required code and provide it to me, since I'm relatively new to this. Thanks much. Snap1.png 26.14KB 0 downloads Snap2.png 149.47KB 0 downloads I'm having a problem and need an answer to why its happening and how to prevent it. Scenario: I begin load my home page which starts with a session_start(); .... Before it FULLY completes loading I try to navigate to another page and BOOM, that page will not load and any other page that begins with session_start(); will not load unless I close and restart the entire browser or wait about 10 minutes.... I will note my website makes ajax calls every 5 seconds or so, but I use setTimeout for them. Any help??? Thanks ahead! Good evening -- My script takes a while to execute as it processes records from the db. I'd like to have it print out to the screen the record id # as it processess each record, just to let me know where it is. Currently, the program waits till the end and then prints out the record numbers, which is no help. How can I enable PHP to print out each record number as it goes along? Thanks! Hi everyone! I've been working on a php script to replace links that contain a query with direct links to the files they would redirect to. <?php $URL1 = file_get_contents('http://www.yahoo.com'); $URL2 = file_get_contents('http://www.google.com'); ?> How would I make PHP load URL1 and URL2 at the same time.. I would add more than 2 urls also, Im tyring to test something with my website, load up to 50 links at once, how would I do this? Thanks I'm having trouble echoing $year in my script. Listed below is the script, just below ,$result = mysql_query("SELECT * FROM $dbname WHERE class LIKE '%$search%'") or die(mysql_error());, in the script I try to echo $year. It doesn't show up in the table on the webpage. Everything else works fine. Any help wold be appreciated greatly. Thanks in advance. <?php include 'config2.php'; $search=$_GET["search"]; // Connect to server and select database. mysql_connect($dbhost, $dbuser, $dbpass)or die("cannot connect"); mysql_select_db("vetman")or die("cannot select DB"); $result = mysql_query("SELECT * FROM $dbname WHERE class LIKE '%$search%'") or die(mysql_error()); // store the record of the "" table into $row //$current = ''; echo "<table align=center border=1>"; echo "<br>"; echo "<tr>"; echo "<td align=center>"; ?> <div style="float: center;"><a><h1><?php echo $year; ?></h1></a></div> <?php echo "</td>"; echo "</tr>"; echo "</table>"; // keeps getting the next row until there are no more to get if($result && mysql_num_rows($result) > 0) { $i = 0; $max_columns = 2; echo "<table align=center>"; echo "<br>"; while($row = mysql_fetch_array($result)) { // make the variables easy to deal with extract($row); // open row if counter is zero if($i == 0) echo "<tr>"; echo "<td align=center>"; ?> <div style="float: left;"> <div><img src="<?php echo $image1; ?>"></div> </div> <?php echo "</td>"; // increment counter - if counter = max columns, reset counter and close row if(++$i == $max_columns) { echo "</tr>"; $i=0; } // end if } // end while } // end if results // clean up table - makes your code valid! if($i > 0) { for($j=$i; $j<$max_columns;$j++) echo "<td> </td>"; echo '</tr>'; } mysql_close(); ?> </table> Hi i have this upload script which works fine it uploads image to a specified folder and sends the the details to the database. but now i am trying to instead make a modify script which is Update set so i tried to change insert to update but didnt work can someone help me out please this my insert image script which works fine but want to change to modify instead Code: [Select] <?php mysql_connect("localhost", "root", "") or die(mysql_error()) ; mysql_select_db("upload") or die(mysql_error()) ; // my file the name of the input area on the form type is the extension of the file //echo $_FILES["myfile"]["type"]; //myfile is the name of the input area on the form $name = $_FILES["image"] ["name"]; // name of the file $type = $_FILES["image"]["type"]; //type of the file $size = $_FILES["image"]["size"]; //the size of the file $temp = $_FILES["image"]["tmp_name"];//temporary file location when click upload it temporary stores on the computer and gives it a temporary name $error =array(); // this an empty array where you can then call on all of the error messages $allowed_exts = array('jpg', 'jpeg', 'png', 'gif'); // array with the following extension name values $image_type = array('image/jpg', 'image/jpeg', 'image/png', 'image/gif'); // array with the following image type values $location = 'images/'; //location of the file or directory where the file will be stored $appendic_name = "news".$name;//this append the word [news] before the name so the image would be news[nameofimage].gif // substr counts the number of carachters and then you the specify how how many you letters you want to cut off from the beginning of the word example drivers.jpg it would cut off dri, and would display vers.jpg //echo $extension = substr($name, 3); //using both substr and strpos, strpos it will delete anything before the dot in this case it finds the dot on the $name file deletes and + 1 says read after the last letter you delete because you want to display the letters after the dot. if remove the +1 it will display .gif which what we want is just gif $extension = strtolower(substr($name, strpos ($name, '.') +1));//strlower turn the extension non capital in case extension is capital example JPG will strtolower will make jpg // another way of doing is with explode // $image_ext strtolower(end(explode('.',$name))); will explode from where you want in this case from the dot adn end will display from the end after the explode $myfile = $_POST["myfile"]; if (isset($image)) // if you choose a file name do the if bellow { // if extension is not equal to any of the variables in the array $allowed_exts error appears if(in_array($extension, $allowed_exts) === false ) { $error[] = 'Extension not allowed! gif, jpg, jpeg, png only<br />'; // if no errror read next if line } // if file type is not equal to any of the variables in array $image_type error appears if(in_array($type, $image_type) === false) { $error[] = 'Type of file not allowed! only images allowed<br />'; } // if file bigger than the number bellow error message if($size > 2097152) { $error[] = 'File size must be under 2MB!'; } // check if folder exist in the server if(!file_exists ($location)) { $error[] = 'No directory ' . $location. ' on the server Please create a folder ' .$location; } } // if no error found do the move upload function if (empty($error)){ if (move_uploaded_file($temp, $location .$appendic_name)) { // insert data into database first are the field name teh values are the variables you want to insert into those fields appendic is the new name of the image mysql_query("INSERT INTO image (myfile ,image) VALUES ('$myfile', '$appendic_name')") ; exit(); } } else { foreach ($error as $error) { echo $error; } } //echo $type; ?> hello, i have a page that parses a string from espn and i have a style sheet that makes it refresh every 2 minutes. the thing that is buggin me is that when i load the page it loades with the last cached data so i have to wait 2 minutes for the info to update. is there any way to force the current content on load, and keep my refresh every 2 minutes still? thanks I'm pretty new to php. But the below script should get news articles from google news rss. It is failing to load the simplexml and returns false. Any idea why? Code: [Select] $url = "http://news.google.com/news?geo=90210"; if ($xml = @simplexml_load_file($url)) { for ($i=0; $i<4; $i++) { $item= $xml->channel->item[$i]; $link= '<a href = "'.(string) $item->link.'", target= "_blank">'.(string) substr($item->title, 0, 50).'...</a><br />'; $news[]= $link; } } I have some FLV files above web root. I want to feed my flv player a php file and an ID. I need that php file to return an flv file basically. So if someone has firebug or something they wont see a video path, but instead see something like: fileserve.php?id=4679 I dont care if a logged in user go directly to that link and it prompts them with a download or whatever. I just want to avoid having a non logged in user do that. |