PHP - Simple Help With Reload Xml File.
Hi,
i'm kind of new with php. i need to make some easy script, that get link of XML file and another "number". and reload the XML file "number" of times. i need to do it with $_GET function. if someone will help me it`ll be greate. Thanks, Or. Similar TutorialsI have an html table that is being populated with links from a specific directory.. I would like the user to be able to click the link and if its a file they will download the file. If its a directory, I woudl like to reload the current page but this time show the contents of the directory. My main issue is that I have a session variable called 'workingdirectory' that I need to update before I reload the page. I have tried setting it and then calling Location('page.php') but I get the 'cannot change header information' error. I realized I was getting this because I had begun to call HTML code before the PHP was finished. Is there a way to just simply update the session variable, and then make the page reload when the user clicks on a link? Hello - First time poster and pretty new to PHP. I have tried to research this before posting but I couldn't find any tutorials with this exact scenario. I am trying to create a PHP file that reads an XML file with the following layout: <Root> - <Vehicle="Red"> <Trip>1108</Trip> <Platform>123RFIES</Platform> <InformationType>Slow</InformationType> </Red> - <Vehicle="Red"> <Trip>1108</Trip> <Platform>123RSHAS</Platform> <InformationType>Fast</InformationType> </Red> I am using the following PHP: <?php $file = "Vehicle.xml"; function contents($parser, $data){ echo $data; } function startTag($parser, $data){ echo "<b>"; } function endTag($parser, $data){ echo "</b><br />"; } $xml_parser = xml_parser_create(); xml_set_element_handler($xml_parser, "startTag", "endTag"); xml_set_character_data_handler($xml_parser, "contents"); $fp = fopen($file, "r"); $data = fread($fp, 80000); if(!(xml_parse($xml_parser, $data, feof($fp)))){ die("Error on line " . xml_get_current_line_number($xml_parser)); } xml_parser_free($xml_parser); fclose($fp); ?> Using this code I can read the entire XML and display it on the webpage. What I am trying to do is filter it so it only displays when InformationType = Fast and only display the Trip and the InformationType. Where do I add this filter logic? Thank you in advance! -Adam Hi i have a simple triple upload file script that upload files with its own name it works fine but what i want is to be able to specify the name of the image like file 1 give name (blue) file 2 name (tree) file 3 name (sky) <?php //set where you want to store files //in this example we keep file in folder upload //$HTTP_POST_FILES['ufile']['name']; = upload file name //for example upload file name cartoon.gif . $path will be upload/cartoon.gif $path1= "images/posters/".$_FILES['ufile']['name'][0]; $path2= "images/posters/".$_FILES['ufile']['name'][1]; $path3= "images/posters/".$_FILES['ufile']['name'][2]; //copy file to where you want to store file copy($_FILES['ufile']['tmp_name'][0], $path1); copy($_FILES['ufile']['tmp_name'][1], $path2); copy($_FILES['ufile']['tmp_name'][2], $path3); //$HTTP_POST_FILES['ufile']['name'] = file name //$HTTP_POST_FILES['ufile']['size'] = file size //$HTTP_POST_FILES['ufile']['type'] = type of file echo "File Name :".$_FILES['ufile']['name'][0]."<BR/>"; echo "File Size :".$_FILES['ufile']['size'][0]."<BR/>"; echo "File Type :".$_FILES['ufile']['type'][0]."<BR/>"; echo "<img src=\"$path1\" width=\"150\" height=\"150\">"; echo "<P>"; echo "File Name :".$_FILES['ufile']['name'][1]."<BR/>"; echo "File Size :".$_FILES['ufile']['size'][1]."<BR/>"; echo "File Type :".$_FILES['ufile']['type'][1]."<BR/>"; echo "<img src=\"$path2\" width=\"150\" height=\"150\">"; echo "<P>"; echo "File Name :".$_FILES['ufile']['name'][2]."<BR/>"; echo "File Size :".$_FILES['ufile']['size'][2]."<BR/>"; echo "File Type :".$_FILES['ufile']['type'][2]."<BR/>"; echo "<img src=\"$path3\" width=\"150\" height=\"150\">"; /////////////////////////////////////////////////////// // Use this code to display the error or success. $filesize1=$_FILES['ufile']['size'][0]; $filesize2=$_FILES['ufile']['size'][1]; $filesize3=$_FILES['ufile']['size'][2]; if($filesize1 && $filesize2 && $filesize3 != 0) { echo "We have recieved your files"; } else { echo "ERROR....."; } ////////////////////////////////////////////// // What files that have a problem? (if found) if($filesize1==0) { echo "There're something error in your first file"; echo "<BR />"; } if($filesize2==0) { echo "There're something error in your second file"; echo "<BR />"; } if($filesize3==0) { echo "There're something error in your third file"; echo "<BR />"; } ?> Hello Friends, I was trying a simple file upload program But it's giving me notice. Heres the HTML & PHP Code. Code: [Select] <html> <body> <form enctype="multipart/form-data" action="uploadFile.php"method="POST"> Select A File: <input type="file" name=uploadedFile"/> <input type="hidden" name="MAX_FILE_SIZE" value="100000"/> <input type="Submit" value="Upload File"/> </form> </body> </html> Code: [Select] <?php $target_path="uploads/"; $target_path=$target_path.basename($_FILES['uploadedFile']['name']); if(move_uploaded_file($_FILES['uploadedFile']['tmp_name'],$target_path)) { echo "The file ".$_FILES['uploadedFile']['name']." is uploaded successfully"; } else { echo "Error uploading file"; } ?> I get the following notice: Notice: Undefined index: uploadedFile in C:\wamp\www\site\html\uploadFile.php on line 3 Notice: Undefined index: uploadedFile in C:\wamp\www\site\html\uploadFile.php on line 5 Error uploading file I cross checked the name of input tag its fine. any help will be highly appreciated! Hello. I want to make a simple website, where I can upload a zip file and download it from a URL with just HTTP GET request. When I download the file, the file will then be deleted on the server. Can't find any examples. Maybe, I've searched wrong. Has somebody some written project links or some tips for me how can I achieve this?
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> Hi. I am trying to create a simple video file server. I finished the skeleton of it but when it came to creating the multitude of pages I realized that there could be an easier way to do it.
I started out basically getting the folder names in the server then printing them on the page.
<?php $dirs = glob("*", GLOB_ONLYDIR); echo '<ul>'; foreach($dirs as $dir) { $forbidden_folders = array("not4u", "ignore", Styles); $filename = str_replace($forbidden_folders, '', $dir); if (!empty($filename)) { echo '<li><a href="'.$dir.'">'.$dir.'</a></li>'; } } echo '</ul>' ?>Then I created in each of the folders with files a php file with this code: <?php function date_sort_desc($a, $b) { preg_match('/\w+ \d{4}/', $a, $matches_a); preg_match('/\w+ \d{4}/', $b, $matches_b); $timestamp_a = strtotime($matches_a[0]); $timestamp_b = strtotime($matches_b[0]); if ($timestamp_a == $timestamp_b) return 0; return $timestamp_a < $timestamp_b; } $files = array(); $dir = opendir('.'); while(false != ($file = readdir($dir))) { if(($file != ".") and ($file != "..") and ($file != "index.php")) { $files[] = $file; } } natsort($files); $i = 0; foreach($files as $file) { $i++; $string = str_replace("TV Show Name S1 E$i - ", '' , $file); echo '<div><a href="../Discriptions/'.$file.'.php">'.basename($string, '.m4v').'</a></div><br>'; } ?>This opens up a php file with the same file name as the file to be played containing the episode's thumbnail and description. That file then contains a link pointing back to the real file. The problem here is that I'd have to make a new php file for every file in my collection. I'm wondering if there's somehow a way to simplify all of this. Edited by chrisyroid, 11 August 2014 - 12:13 AM. hello dear PHP-experts have set up a server at localhost with phpMyAdmin i get back the site " it works " if i type in localhost i get access to the phpMyAdmin if i type localhost/phpMyAdmin so far so good now i wanted to go ahead: i ve uploaded a file called php_info.php to the htdocs folder. i changed permissions accordingly. (see below) linux-c5sz:/srv/www/htdocs # ls -l insgesamt 28 -rwxrwxrwx 1 root root 302 13. Mär 2006 favicon.ico drwxrwxrwx 2 root root 4096 6. Nov 2013 gif -rwxrwxrwx 1 root root 45 11. Jun 2007 index.html -rwxrwxrwx 1 root root 2356 28. Sep 2013 info2html.css -rwxrwxrwx 1 martin users 188 3. Dez 19:07 php_info.php drwxrwxrwx 6 root root 4096 3. Nov 17:40 phpMyAdmin -rwxrwxrwx 1 root root 26 13. Okt 15:32 robots.txt linux-c5sz:/srv/www/htdocs #what makes me wonder is - i cannot see the content of the file of php_info.php - why is this so see below <?php // Zeigt alle Informationen (Standardwert ist INFO_ALL) phpinfo(); // Zeigt nur die Modul-Informationen. // phpinfo(8) führt zum gleichen Ergebnis. phpinfo(INFO_MODULES); ?>well i wonder why i cannt see any information in thebrowser is this a bug ? I have a div that displays the contents of a mysql table. When the users adds to the table/presses a button I want it to fade out, reload, and fade back in with the new content there. The current PHP code is in its own div called 'stream'... <script> function buttonFunction() { v=$("#txtstatus"); $.post('../action/poststatus.php',{status:v.val()},function(d){ $('div#stream').fadeOut('slow'); $('div#stream').load; $('div#stream').fadeIn('slow'); }); } </script>This fades out and back in but with nothing new loaded. Please help. Thanks, Hi I have this script i wrote which show four random business from my database inline. Now I want this script to show the four results for 5 seconds and then show another 4 businesses for 5 seconds and so on. Can someone please point me in the right direction as to what I need to be looking up to do this as I dont know where to begin. here is the code by the way <?php $qGetUsers = "SELECT * FROM business ORDER BY rand() LIMIT 4"; $rGetUsers = mysql_query($qGetUsers) or die(mysql_error()); while($allUsers = mysql_fetch_array($rGetUsers)) { ?> <table id="top4tbl" width="150px" height="141px" border="0" cellpadding="0" cellspacing="5"> <tr> <td width="150" ><div align="center"><img src="<?php echo $allUsers['image_location'];?>" /> </div></td> </tr> <tr> <td width="150" ><div align="center"><strong><?php echo $allUsers['Business_name'];?> </strong></div></td> </tr> <tr> </tr> <tr> <td width="150" height="20"><div align="center"><a href="businessinformation.php?businessid=<?php echo $allUsers['businessid'];?>">More Info</a></div></td> </tr> </table> <?php } ?> Hi is there any way we can prevent suppose <textarea></textarea> when page reload it refresh and set default text i wanted to know is there any way to prevent certain things not to get refreshed is there any method in php which prevent to reload this ! <?php echo "<textarea > Enter your favorite quote!</textarea> \n" ; Code: [Select] if (isset($_GET['edit']) && $_GET['edit'] == 'textupdate'){ } <a href= \"{$_SERVER['PHP_SELF']}?page=1&edit=textupdate \" >Click</a>?> aside from file_get_contents(); is there a way to reload a header quicker than that file_get_contents offer? How would I set up a HEAD request to load a header? Thanks I had another thread about a problem I was having where it's not loading from the DB right aways. My solution is to make an update function and then have the id's calling it on the page. So the thing I am wondering is how to make a working update function. I have this so far: <?php include blah.... $uid = $_SESSION["user"][0]; $avatarid = $_SESSION["user"][12]; function update($str) { global $db_id; $query="select ".$str." from users where id=".$uid; $result=mysql_query($query, $db_id); $row=mysql_fetch_row($result); return $row[0]; } ?> and then it's being called on the profile page with <?php echo update($avatarid); ?>. I want the update() function to select avatar from users where id = userid and then return the value fresh so it's getting it new from the database every time they refresh the page. Then there won't be a problem with updating old avatar stuff. Currently gives me the error: Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in /home/root/public_html/func.php on line 69 So what am I doing wrong here? thanks for anyone who can help For those willing to run this sample problem, reference the 2 files below. You will need to create an Excel file called blank.xls and put it in the same directory as these 2 files. When you launch indexTest.php, it will load the formTest.html.php page. This form has 3 options on it: 1. Export Excel - will prompt you to download the Excel file you made and should clear the error message on the form 2. Test Flag - tests the functionality of clearing the error message, shows what should happen when the Export Excel option is selected 3. Reset - resets back to initial state I really need the Export Excel option to be allow the form to reload properly. This is a problem that I have been wresting with for awhile and need a solution. Hopefully someone can give me some insight on how to get this to work. indexTest.php <?php $frmErrorLevel=1; $frmErrMsg='Error Level 1 indicated'; if(isset($_POST['action']) && $_POST['action']=='submitted') { if(isset($_POST['ExportCarrier'])) { $download_filename = "blank.xls"; $FileInfo = pathinfo($download_filename); // fix for IE catching or PHP bug issue header("Pragma: public"); header("Expires: 0"); // set expiration time header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); // browser must download file from server instead of cache // force download dialog header("Content-Type: application/force-download"); header("Content-Type: application/octet-stream"); header("Content-type: application/x-msexcel"); header("Content-Type: application/download"); // use the Content-Disposition header to supply a recommended filename and // force the browser to display the save dialog. header("Content-Disposition: attachment; filename=".$download_filename.";"); header("Content-Transfer-Encoding: binary"); header("Content-Length: ".filesize($download_filename)); @readfile($download_filename); //ob_end_clean(); $frmErrorLevel=0; } if(isset($_POST['Test_Flag']) && $_POST['Test_Flag']=='Test Flag'){ $frmErrorLevel=0; $frmErrMsg=''; } } include ('formTest.html.php'); exit(); ?> formTest.html.php <?php ini_set ("display_errors", "1"); error_reporting(-1); echo "<pre>"; echo "--> Form data (POST) <-- <br>"; print_r ($_POST); echo "--> Form data (GET) <-- <br>"; print_r ($_GET); echo "</pre>"; ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Export Trucking Data</title> </head> <body> <h1>Export Data</h1> <form action="" method="post"> <?php if($frmErrorLevel>0) { echo '<font color=#CC6600 size=+1>'.$frmErrMsg.'</font><br><br>'; } ?> <table width="650" border="0"> <caption> <font size="+3">Data Export Options</font> </caption> <tr> <td> <?php if($frmErrorLevel==1) print '<img src= "..\..\images\rdx.gif">'; else echo " "; ?> </td> <td width="275"><label> Carrier table data</label></td> <td width="100"><input name="ExportCarrier" type="submit" value="Export Excel"></td> <td> <div align="center"> <td><input type="submit" name="Test Flag" value="Test Flag"></td> <td> <div align="center"> <td><input type="submit" name="Reload Form" value="Reset"></td> </tr> </table> <div> <input type="hidden" name="action" value="submitted" /> </div> </form> </body> </html> Can someone help me with a code , which can make a select form to reload the page or the form in the moment when a option from it , is been selected.
i try it whit onClick="document.location.reload()"; but doesn't work properly.
thx
Ok, so I am trying to make a database with PHP and I hit a snag. First off, here is the code in question. Code: [Select] <?php //GET CONFIG include_once('../scripts/config.inc.php'); //SET VARIABLES TO SOMETHING A BIT SHORTER FOR THE DATABASE OPTIONS $host = $config['db_settings']['db_host']; $user = $config['db_settings']['db_user']; $pass = $config['db_settings']['db_pass']; $prefix = $config['db_settings']['db_prefix']; $db = $config['db_settings']['db_name']; $con = mysql_connect($host, $user, $pass); $select_db = mysql_select_db($db); $c_tables = ''; $c_database = "CREATE DATABASE IF NOT EXISTS $db;"; //NOW CONNECT TO THE SERVER if ($con){ echo('Connected Succesfully to the Server <br />'); } else die('Could not connect to database: ' . mysql_error()); //NOW CONNECT TO THE DATABASE if ($select_db){ echo('Selected Database Succesfully <br />'); } //IF DATABASE COULD NOT BE SELECTED THEN TRY TO MAKE IT else if(!$select_db){ echo('Could not select the databse. Trying to create it... <br />'); if(mysql_query($c_database)){ echo('Database has been created...<br />'); if($select_db){ echo('Database Has Been Selected.'); } else die('Can not select database!' . mysql_error()); } else die('Could not created the database!'); } else die ('Could not create or select the database!: ' . mysql_error() . '<br />'); //NOW CREATE THE TABLES mysql_close; ?>The problem is, that if I drop the database to test that it creates the database, it does indeed make it, but after it makes the database it will not select it until I reload the page and intern the script. So this is the output I would get. (The fact that there is no error is what is causing me to be confused) 1st load that makes new database: Quote Connected Succesfully to the Server Could not select the databse. Trying to create it... Database has been created... Can not select database! 2nd load that should not be needed to select the database: Quote Connected Succesfully to the Server Selected Database Succesfully hello guys, i have a question, in some php files i have in the start <? ob_start(); ?> <?php session_start(); ........ ..... ...... if(isset($_POST['sub_1'])) { $_SESSION['address_tmp']=$_SESSION['address_tmp']." oK "; header("location:some_other_page.php#jumpselection"); } if(isset($_POST['sub_2'])) { $_SESSION['address2_tmp']=$_SESSION['address2_tmp']." hello "; header("location:thispage.php#jumpselection"); } ?> <body> <form method="post" action=""> <input type="Submit" name="sub_1" value="action1"style="height:3.9em; width:16.5em; font-size:95%;"> </form> </body> <body> <form method="post" action=""> <input type="Submit" name="sub_2" value="action2"style="height:3.9em; width:16.5em; font-size:95%;"> </form> </body> <? ob_end_flush(); ?> but every page have 10-15 buttons every button in the end reloads the same page with header("location:thispage.php#jumpselection"); or cals another page with header("location:some_other_page.php#jumpselection"); this works but i notise some lag on the bowser afrer while.. I would like the page orderform.php to reload or refresh to normal after I click this link: this is what i have and this link is on a different page though... if($myError==true) echo "<br /><br />Click here to <a href='orderform.php?nocache='.time().'>go back...</a>"; else header("location: orderform.php"); Hello dear friends, I've very annoying problem my website is for child drawing (draw.php) after child do drawing will click on submit (form) by sending it to another page (thanks.php) | | | | data will be submitted to database and gives message saying ( thank you for ...blah blah blah) here is the problem if he refresh the page , it will also add entry to the database so imagine if someone did many many refresh, i will get many many empty entry into database how to stop this ? here is simple code based on this problem Code: [Select] <form name="frm" method="post" action="thanks.php"> <input type="text" name="name" id="name" value=""> <input type="text" name="email" id="email" value=""> <button type="submit">Submit</button> </form> and the (thanks.php) file code *assume we have connection to db Code: [Select] $sql = "INSERT INTO $table (name, email) VALUES ('$name', '$email')"; mysql_query($sql, $conn) or die(mysql_error()); echo "Thank you kid..nice drawing"; now my problem if (thanks.php) got refreshed it will also will add empty entry to database can anyone please help me how to stop it. |