PHP - Head Function Loads In Body
Hello,
I've made a function that contains the html header (<head>). When I call that function in a other file, with the header file included, it puts the header function in the body. So all the meta tags are in the body, instead of the head.
Would it be possible to load this all in the head?
The head function does contain the html and head tags. However, without them, it still doesn't want to go to the head.
Similar TutorialsIt's not usual I ask questions on here - I usually help rather than be helped but alas, this is really confusing ! Short Story (You can skip this to "Your Mission") Without going into unnecessary detail i'll try to explain what i'm trying to do; Take an array (example provided...) Array( // These must be here, they are initially read by the template parser to get a starting point. "data"=>Array( "template"=>"main", // Template to start from (base template) "content"=>"%custom_topmenu% <Br/>Table<Br/> %bigtablecustom1%", // replace %content% tag,Shows 2 Examples, A Custom Menu, and Main Table with Smaller Tables inside ), // Below is numerically indexed arrays of content that will replace tags in the above "content" item 0=>Array( "data"=>Array( "rkey"=>"%bigtablecustom1%", // MUST have this item "template"=>"bigtable_single", // MUST have this item 0=>Array( "%title%"=>"Some Table Heading", "%footer%"=>"Some Table Footer Message (author?)", "%content%"=>"Some Content for the table with another rkey: %smalltablecustom1% --- %smalltablecustom2%", "%title_note%"=>"Some Time and Date" ) ), 0=>Array( "data"=>Array( "rkey"=>"%smalltablecustom1%", "template"=>"smalltable_single", 0=>Array( "%title%"=>"Small Title", "%content%"=>"Some Small Content or Note" ) ) ), 1=>Array( "data"=>Array( "rkey"=>"%smalltablecustom2%", "template"=>"smalltable_single", 0=>Array( "%title%"=>"Small Title 2", "%content%"=>"Some Small Content or Note" ) ) ) ) 1=>Array( // The menu is dynamically created by the module using it's inherited protected methods. "data"=>Array( "rkey"=>"%custom_topmenu%", "template"=>"custom_topmenu", 0=>Array( "%item1_name%"=>"Sub-Link 1", "%item1_link%"=>"#", "%item2_name%"=>"Sub-Link 2", "%item2_link%"=>"#", "%item3_name%"=>"Sub-Link 3", "%item3_link%"=>"#", "%item4_name%"=>"Sub-Link 4", "%item4_link%"=>"#" ) ) ) ) Turn this array into a single document, basically collpase all items with their children in the parent code. The Problem (You can skip this to "Your Mission") Now to make it easier and to (try) to prevent cross-tag contamination (so templates dont replace content that is supposed to be there from other template files...) I have wrote a recursion function that fills out all the content and removes the content sub-array from the data arrays (half the job). So now I have a multi-dimensional array that needs collapsing into a single document (variable), I am getting confused with how to go through this array (below - not above) so that all the template items are "inserted" inside their parent array items. The Function I made // Recursive, goes through an array and converts any "data" into actual templates. (Puts the content into a template) private function parse_template_data_array($array){ // First let's count how many items are in the array that was passed to us $item_count = count($array); // This should never happen, each array should have at least a "data" array inside. if($item_count < 1){ // Template Parser Fatal Object Syntax Error exit("FATAL PARSER ERROR1"); // If there is only one item, we don't need to recurse (There are no "child" elements) and so we skip the recursive section. }else if($item_count == 1){ // No items to parse, move on // So there are some child elements we must recurse through. }else{ // So this loops each "Child" element and passes that array to this function (recurse), Once it's finished it saves the array (result). for($i=0;$i<($item_count-1);$i++){ // -1 from the count, 1 to get rid of the data array. $array[$i] = $this->parse_template_data_array($array[$i]); } } // This part does the initial "template expansion", it finds the template needed for this item and saves it with the content to this item. // So we count how many data items we have $dcount = count($array['data']); // Count Data Items (minimum of 2 - Each data array must have "rkey" and "template") // If there isn't at least two items then someone made a booboo. if($dcount < 2){ // Template Parser Fatal Object Syntax Error exit("FATAL PARSER ERROR2"); // Otherwise let's sort this content out (We don't check if we only have the 2 minimum items since templates might not have Tags to replace). }else{ // Load Template file using the "template" item in the data array. $template = $this->get_file($array['data']['template']); // Count the amount of data items (content) to replace tags inside the loaded template (If there is no content sub-array then put to 0 to skip the below part). $dstrcount = (isset($array['data'][0]))? count($array['data'][0]) : 0; // No template content, maybe no tags, just give the template content back. if($dstrcount < 1){ // No items to parse // We have some content to replace. }else{ // We need the keys of the content sub-array so we can use (a neat feature of) the str_replace function. $akeys = array_keys($array['data'][0]); $template = str_replace($akeys ,$array['data'][0],$template); } // Save the result into this array item so we can pass the whole item back (This is also what happens when it recurses above) $array['data']['content'] = $template; } // Return the result array. return $array; } The Array returned by the above function Array ( [data] => Array ( [rkey] => %cdb_res_tpl_blk% [template] => main [content] => <html><head></head><body>%custom_topmenu%<br />%bigtablecustom1%</body></html> ) [0] => Array ( [data] => Array ( [rkey] => %bigtablecustom1% [template] => bigtable_single [content] => "Some Table Heading"=>"Some Table Heading", "Some Table Footer Message (author?)"=>"Some Table Footer Message (author?)", "Some Content for the table with another rkey: %smalltablecustom1% --- %smalltablecustom2%"=>"Some Content for the table with another rkey: %smalltablecustom1% --- %smalltablecustom2%", "Some Time and Date"=>"Some Time and Date" ) [0] => Array ( [data] => Array ( [rkey] => %smalltablecustom1% [template] => smalltable_single [content] => "Small Title"=>"Small Title", "Some Small Content or Note"=>"Some Small Content or Note" ) ) [1] => Array ( [data] => Array ( [rkey] => %smalltablecustom2% [template] => smalltable_single [content] => "Small Title 2"=>"Small Title", "Some Small Content or Note"=>"Some Small Content or Note" ) ) ) [1] => Array ( [data] => Array ( [rkey] => %custom_topmenu% [template] => custom_topmenu [content] => "Sub-Link 1"=>"Sub-Link 1", "#"=>"#", "Sub-Link 2"=>"Sub-Link 2", "#"=>"#", "Sub-Link 3"=>"Sub-Link 3", "#"=>"#", "Sub-Link 4"=>"Sub-Link 4", "#"=>"#" ) ) ) Your mission (Should you choose to accept ofc ), is to take the above array and turn it into a single html variable, with all the child elements inside their parent templates by replacing the tags in the array. All the data required is in the array, all that is needed is to "collapse" the array. Things to bear in mind: %cdb_res_tpl_blk% - This is in the original template file, so the result of a successfull collapse will replace this tag with the result. Dont worry about this one [rkey] - This is the "Tag" to replace in the "parent" content. [template] - This is the template file. [content] - This is the content that needs to go inside the parent item. Expected Result <html><head></head><body>"Sub-Link 1"=>"Sub-Link 1", "#"=>"#", "Sub-Link 2"=>"Sub-Link 2", "#"=>"#", "Sub-Link 3"=>"Sub-Link 3", "#"=>"#", "Sub-Link 4"=>"Sub-Link 4", "#"=>"#"<br />"Some Table Heading"=>"Some Table Heading", "Some Table Footer Message (author?)"=>"Some Table Footer Message (author?)", "Some Content for the table with another rkey: "Small Title"=>"Small Title","Some Small Content or Note"=>"Some Small Content or Note" --- "Small Title 2"=>"Small Title","Some Small Content or Note"=>"Some Small Content or Note""=>"Some Content for the table with another rkey: %smalltablecustom1% --- %smalltablecustom2%", "Some Time and Date"=>"Some Time and Date"</body></html> I will be working on this myself and if I find a solution I will post here. It is just that the way I code is I put my idea in my head, then try to code it in my head categorically, but when I think I find a solution it seems there is a bug, such as it will only collpase the main element, the bigtable, and the first small table, it wont do the other small table and not the menu either so basically it doesnt recurse items in the same array, only those underneath it. I'm so close but yet...so far... THANK YOU for ANY light you can shed on this situation it's been bugging me for a few days now (admittely have not coded since my first attempt - so tired.) My Code I won't provide the code I've done for it now since it just flat-out doesn't work, I've lost the code that I mentioned earlier that was bugged I modified and to be perfectly honest can't be bothered to reproduce it (it won't get me anywhere). Hi All, I am a newbie to php and I have this issue. I would appreciate if anyone can help out. I tried a few things but was not able to come up with a solution. From reading few codes and learning from it, I created this function in query.php and am calling this function in uk.php file, but the problem is that it loads and shows the data in table, but then it stops loading page from there on and the footer which is in html code after the place where I am calling this function does not load. I tried removing return false; command, but with that it loads the footer, but it shows the table after the footer. I want the table with data to show in between header and footer. Can you guys let me know what I need to do to achieve that? File Name: query.php
function uk() { $output = ''; $result = db_query("SELECT * FROM lecture where groups='uk'"); if(mysqli_num_rows($result) > 0) { $output .= '<div id="style2" style="overflow-x:auto;"> <table> <tr> <th class="text-center">Date</th> <th class="text-center">Title</th> <th class="text-center">Venue</th> <th class="text-center">Duration</th> <th class="text-center">Size (MB)</th> <th class="text-center">Link</th> </tr>'; while($row = mysqli_fetch_array($result)) { $output .= ' <tr> <td>'.$row["mydate"].'</td> <td>'.$row["title"].'</td> <td>'.$row["venue"].'</td> <td>'.$row["duration"].'</td> <td>'.$row["size"].'</td> <td><a href="../'.$row["path"].$row["file_name"].'">Save</a></td> </tr> '; } echo $output; } else { echo 'Data Not Found'; } }
File Name: uk.php
Header html code here Some body text <?php include '../includes/query.php'; uk(); return false; ?> Footer html code here
Ok, so I've read a few tutorials of OOP and have a basic understanding of how it works but where is it generally handy? I have a basic site created with PHP that consists of a form that submits data to MySQL and then lists the data from the MySQL database on another page. Kind of like a little online planner. I don't see how me converting my site to use OOP would help here. Maybe it's best for more complex situations such as a shopping cart where data needs to be shared across multiple pages? first i have a standard html page. Just a form that submits data to upload.php http://pixel.imgboard.co.uk here is upload.php - note i know i have some weird echo's but ive been trying for 2 hours to get upload.php to display something... but nothing happens.. i cant even get it to output html. It just goes to upload.php and has a blank page. When i view source there is nothing there. Its literally a blank page. I can't work it out. someone please help. I'm going to crack up. <?php ini_set("display_errors", "1"); error_reporting(E_ALL); session_start(); include 'http://www.imgboard.co.uk/includes/functions.php'; $start = " <!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"> <html> <head> <link rel=\"stylesheet\" type=\"text/css\" href=\"http://www.imgboard.co.uk/style/pixel.css\" /> <title> Pixel - Image Hosting Beta</title> </head> <body> <div id =\"wrapper\"> <div class = 'titlebar'> <div class = 'titlebarlinkbox'> <a href = 'http://www.imgboard.co.uk'>Forum</a> <a href = 'http://www.imgboard.co.uk/Wiki.php'>Wikis</a> <a href = 'http://www.imgboard.co.uk/bulletins/0'>Bulletins</a> <a href = 'http://www.imgboard.co.uk/faq/0'>Faq's</a> </div> </div> <div class = \"logo\"></div> "; $end = " <div class = 'footerLinks'> Pixel @ 2010 - 2015 ! <br /> <a href = 'http://www.imgboard.co.uk'>Forum</a> | <a href = 'http://www.imgboard.co.uk/Wiki.php'>Wikis</a> | <a href = 'http://www.imgboard.co.uk/bulletins/0'>Bulletins</a> | <a href = 'http://www.imgboard.co.uk/faq/0'>Faq's</a> | <a href = 'http://www.imgboard.co.uk/pixel/report.php'>Report Image</a> </div> <div class = 'TnC'>Pixel is a Trademark of imgboard.co.uk. Please ensure all content uploaded is decent. No Taboo, cp, gore allowed. Porn / memes / misc themes all welcome. Any offensive content will be removed and deleted. Any misuse of the service and result in banning and in seviere cases prosecution.</div> </div> </body> </html> "; if(isset($_GET['uploadfile'])){ echo $start; echo $end; $validExtensions = array("png", "gif", "jpeg", "jpg", "bmp"); $ext = end(explode(".",$_FILES["image"]["name"])); $ext2= strtolower($ext); if ((($_FILES["file"]["type"] == "image/gif") || ($_FILES["file"]["type"] == "image/jpeg") || ($_FILES["file"]["type"] == "image/png") || ($_FILES["file"]["type"] == "image/bmp") || ($_FILES["file"]["type"] == "image/pjpeg")) && ($_FILES["file"]["size"] < 10000000)) && in_array($ext2,$validExtensions)) { //create a unique name. $newname = date(dmYhis); $newname .= rand(1111,9999); //preg replace non alpha numeric characters $fname = $_FILES['file']['name']; $newname = $newname . "." .$ext2; $location = "http://www.imgboard.co.uk/images/".$newname; //copy the file. if(move_uploaded_file($_FILES['file']['tmp_name'],$location)){ //file uploaded create display Page. $t = $_POST['tags']; add_uploaded_image($location,$t); file_upload_display_page($location); } else{ die("Error Occured Moving File"); } } else{ die("wrong mime type"); } } function add_uploaded_image($link, $tags){ $c = protect($_COOKIE['supercookie']); $ip = $_SERVER['REMOTE_ADDR']; $t = protect($tags); mysql_query("INSERT INTO pixel (filename,tags,date,ip,cookie) VALUES ('$link','$t',NOW(),'$ip','$c')") or die(mysql_error()); } function file_upload_display_page($location){ echo " <table class = 'uploadTable' cellspacing = '0'> <tr> <td class = \"label\"> Image Uploaded: </td><td><img src = '$location' HEIGHT = '150'/> </td> </tr> <tr> <td class = \"label\"> Direct Link: </td><td><input type = 'text' name = 'file' id = 'file' value = '$location'/> </td> </tr> <tr> <td class = \"label\"> Html Code </td><td><input type = 'text' name = 'tags' value = \"<img src = '$location' ALT = 'Hosted On http://Pixel.imgboard.co.uk'/>\"/> </td> </tr> <tr> <td> <td class = \"label\"> BB Code: </td><td><input type = 'text' name = 'file' id = 'file' value = '[img]http://$location[/img]'/> </td> </td> </tr> </table> "; } hey guys how you doing? I've been having a little bit of problem with php, in fact I'm frustrated, so please if you can help me in any tight of way, please do, I've been trying to make this php code work, but it won't, i don't know what I'm doing wrong, I'm new to php and mysql every time i try it, it saids one thing Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\siteN\approvescore.php:3) in C:\xampp\htdocs\siteN\authorize.php on line 17 <?php require_once ('authorize.php'); ?> <!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" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Guitar Wars - Approve a High Score</title> <link rel="stylesheet" type="text/css" href="style.css" /> </head> <body> <h2>Guitar Wars - Approve a High Score</h2> <?php require_once('appvars.php'); require_once('connectvars.php'); if (isset($_GET['id']) && isset($_GET['date']) && isset($_GET['name']) && isset($_GET['score'])) { // Grab the score data from the GET $id = $_GET['id']; $date = $_GET['date']; $name = $_GET['name']; $score = $_GET['score']; $screenshot = $_GET['screenshot']; } else if (isset($_POST['id']) && isset($_POST['name']) && isset($_POST['score'])) { // Grab the score data from the POST $id = $_POST['id']; $name = $_POST['name']; $score = $_POST['score']; } else { echo '<p class="error">Sorry, no high score was specified for approval.</p>'; } if (isset($_POST['submit'])) { if ($_POST['confirm'] == 'Yes') { // Connect to the database $dbc = mysqli_connect('localhost', '999', 'adsd', 'guitarwars3'); // Approve the score by setting the approved column in the database $query = "UPDATE gtwars1 SET approved = 1 WHERE id = $id"; mysqli_query($dbc, $query); mysqli_close($dbc); // Confirm success with the user echo '<p>The high score of ' . $score . ' for ' . $name . ' was successfully approved.'; } else { echo '<p class="error">Sorry, there was a problem approving the high score.</p>'; } } else if (isset($id) && isset($name) && isset($date) && isset($score)) { echo '<p>Are you sure you want to approve the following high score?</p>'; echo '<p><strong>Name: </strong>' . $name . '<br /><strong>Date: </strong>' . $date . '<br /><strong>Sco </strong>' . $score . '</p>'; echo '<form method="post" action="approvescore.php">'; echo '<img src="' . GW_UPLOADPATH . $screenshot . '" width="160" alt="Score image" /><br />'; echo '<input type="radio" name="confirm" value="Yes" /> Yes '; echo '<input type="radio" name="confirm" value="No" checked="checked" /> No <br />'; echo '<input type="submit" value="Submit" name="submit" />'; echo '<input type="hidden" name="id" value="' . $id . '" />'; echo '<input type="hidden" name="name" value="' . $name . '" />'; echo '<input type="hidden" name="score" value="' . $score . '" />'; echo '</form>'; } echo '<p><a href="admin.php"><< Back to admin page</a></p>'; ?> Hi All, I am trying to use headers at the end of functions to put the user where they need to be. header("location: register.php?user_may_exist"); I understand how they work and their qwuirks. My issue is, in my head file, i am outputting which causes issues for the headers which come after. I have the following in head.php <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title> <?php if(isset($currentPageTitle)){ echo $currentPageTitle; }else{ echo 'Cricket Club'; }; ?> </title> <?php if(isset($currentPageMeta)){ echo "<meta name='description' content='$currentPageMeta'>"; }else{ echo "<meta name='description' content='All the latest from CC'>"; }; ?> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> Is there a better way for me to achieve this? how you doing guys. I'm having a little bit of a problem right now, with this thing call view-profile.php, i hope you guys know what it is, I'm new to php, so please try to help. it says the same thing everytime. Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in C:\xampp\htdocs\siteS\viewprofile.php on line 26 There was a problem accessing your profile <h3>Mismatch - View Profile</h3> <?php require_once('appvars.php'); require_once('connectvars.php'); // Connect to the database $dbc = mysqli_connect('localhost', '***', '*****', '*****'); // Grab the profile data from the database if (!isset($_GET['user_id'])) { $query = "SELECT username, first_name, last_name, gender, birthdate, city, state, picture FROM mismatch_user WHERE user_id = '$user_id'"; } else { $query = "SELECT username, first_name, last_name, gender, birthdate, city, state, picture FROM mismatch_user WHERE user_id = '" . $_GET['user_id'] . "'"; } $data = mysqli_query($dbc, $query); line26-----------> if (mysqli_num_rows($data) == 1) { // The user row was found so display the user data $row = mysqli_fetch_array($data); echo '<table>'; if (!empty($row['username'])) { echo '<tr><td class="label">Username:</td><td>' . $row['username'] . '</td></tr>'; } if (!empty($row['first_name'])) { echo '<tr><td class="label">First name:</td><td>' . $row['first_name'] . '</td></tr>'; } if (!empty($row['last_name'])) { echo '<tr><td class="label">Last name:</td><td>' . $row['last_name'] . '</td></tr>'; } if (!empty($row['gender'])) { echo '<tr><td class="label">Gender:</td><td>'; if ($row['gender'] == 'M') { echo 'Male'; } else if ($row['gender'] == 'F') { echo 'Female'; } else { echo '?'; } echo '</td></tr>'; } if (!empty($row['birthdate'])) { if (!isset($_GET['user_id']) || ($user_id == $_GET['user_id'])) { // Show the user their own birthdate echo '<tr><td class="label">Birthdate:</td><td>' . $row['birthdate'] . '</td></tr>'; } else { // Show only the birth year for everyone else list($year, $month, $day) = explode('-', $row['birthdate']); echo '<tr><td class="label">Year born:</td><td>' . $year . '</td></tr>'; } } if (!empty($row['city']) || !empty($row['state'])) { echo '<tr><td class="label">Location:</td><td>' . $row['city'] . ', ' . $row['state'] . '</td></tr>'; } if (!empty($row['picture'])) { echo '<tr><td class="label">Pictu </td><td><img src="' . MM_UPLOADPATH . $row['picture'] . '" alt="Profile Picture" /></td></tr>'; } echo '</table>'; if (!isset($_GET['user_id']) || ($user_id == $_GET['user_id'])) { echo '<p>Would you like to <a href="editprofile.php">edit your profile</a>?</p>'; } } // End of check for a single row of user results else { echo '<p class="error">There was a problem accessing your profile.</p>'; } mysqli_close($dbc); ?> include "header.php"; if(isset($_GET['post_id'])) { $select=mysqli_query($con,"select...."); while($data=mysqli_fetch_array($select)) { echo "bla bla bla"; to_head("<title>asd</title><meta itemprop="name" content="asdfasdf">..."); } } include "footer.php";This is samthing what i want... I have header.php and footer.php and any script ex news.php where how news and read SEO stuff from database and put in HEAD of the document. I tried with jquery like $("head").append(str); and it works but then i read google don't run jquery when vist website. This is done with drupal, wordpress and php-fusion Drupal: https://api.drupal.o...add_html_head/7 php-fusion: https://www.php-fusi...thread_id=30959 so it is possible but i don't know how. Any idea? I'm trying to create a web ' order form ' basically i've been trying to miss match different guides online and im very confused! Can someone fix it so it would e-mail me the data I have a PHP enabled web host / server... all this is very new to me and its a complex form i need Thanks In advance! this is the code I have : </head> <body> <form> <form method="POST" action="thanks.php"> <table border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#3E55A7" bgcolor="#C7CFE9"> <tr> <td colspan="10" bgcolor="3e55a7" class="style9"><div align="center">CUSTOMER ORDER FORM </div> <div align="center"></div></td> </tr> <tr bordercolor="#F5F4FD" bgcolor="#C7CFE9"> <td colspan="10" bgcolor="#C7CFE9"><div align="center"></div></td> </tr> <tr bordercolor="#F5F4FD" bgcolor="#C7CFE9"> <td colspan="4" class="style17"><strong>NAME <input name="custname" type="text" class="style17" tabindex="1" size="53"> </strong></td> <td width="86"> </td> <tr bordercolor="#F5F4FD" bgcolor="#C7CFE9"> <td colspan="4" class="style17"><strong>ADDRESS<span class="style15"> <textarea name="custadd" cols="50" class="style17" tabindex="2"></textarea> </span></strong></td> <td class="style15"> </td> </tr> <tr bordercolor="#F5F4FD" bgcolor="#C7CFE9"> <td height="24" colspan="4" class="style17">TOWN<span class="style15"> <input name="custtown" type="text" class="style17" id="custtown" tabindex="3" size="53"> </span></td> <td class="style15"> </td> </tr> <tr bordercolor="#F5F4FD" bgcolor="#C7CFE9"> <td height="24" colspan="4" class="style17"><strong>POSTCODE<span class="style15"> <input name="custcode" type="text" class="style17" id="custcode" tabindex="3.5" size="53"> </span></strong></td> <td class="style15"> </td> </tr> <tr bordercolor="#F5F4FD" bgcolor="#C7CFE9"> <td height="27" colspan="4" class="style17"><strong>PHONE<span class="style15"> <input name="custphone" type="text" class="style17" id="custphone" tabindex="4" size="53"> </span></strong></td> <td class="style15"> </td> </tr> <tr bordercolor="#F5F4FD" bgcolor="#C7CFE9"> <td height="42" colspan="4" class="style17"><strong>EMAIL<span class="style15"> <input name="re_Email" type="text" class="style17" id="re_Email" tabindex="5" size="53"> </span></strong></td> <td class="style15"> </td> </tr> <tr bgcolor="#F5F4FD"> <td width="94">Item Number </td> <td width="86">Page Number </td> <td width="84">Product Code </td> <td width="215">Description</td> <td>Price</td> <td width="62">QTY</td> <td width="57">Total</td> </tr> <tr bgcolor="#F5F4FD"> <td>1</td> <td><input name="pg2" type="text" class="style17" id="pg2" tabindex="13" size="8"></td> <td><input name="pg2" type="text" class="style17" id="pg2" tabindex="13" size="8"></td> <td><input name="cd2" type="text" class="style17" id="cd2" tabindex="14" size="9"></td> <td><input name="desc2" type="text" class="style17" id="desc2" tabindex="15" size="12"></td> <td bordercolor="#3E55A7"><input name="price2" type="text" class="style17" id="price2" tabindex="16" size="6"></td> <td><input name="qty2" type="text" class="style17" id="qty2" tabindex="17" size="3"></td> </tr> <tr bgcolor="#F5F4FD"> <td>2</td> <td><input name="pg3" type="text" class="style17" id="pg3" tabindex="18" size="8"></td> <td><input name="pg3" type="text" class="style17" id="pg3" tabindex="18" size="8"></td> <td><input name="cd3" type="text" class="style17" id="cd3" tabindex="19" size="9"></td> <td><input name="desc3" type="text" class="style17" id="desc32" tabindex="20" size="12"></td> <td><input name="price3" type="text" class="style17" id="price3" tabindex="21" size="6"></td> <td><input name="qty3" type="text" class="style17" id="qty3" tabindex="22" size="3"></td> </tr> <tr bgcolor="#F5F4FD"> <td>3</td> <td><input name="pg4" type="text" class="style17" id="pg4" tabindex="23" size="8"></td> <td><input name="pg4" type="text" class="style17" id="pg4" tabindex="23" size="8"></td> <td><input name="cd4" type="text" class="style17" id="cd4" tabindex="24" size="9"></td> <td><input name="desc4" type="text" class="style17" id="desc42" tabindex="25" size="12"></td> <td><input name="price4" type="text" class="style17" id="price4" tabindex="26" size="6"></td> <td><input name="qty4" type="text" class="style17" id="qty42" tabindex="27" size="3"></td> </tr> <tr bgcolor="#F5F4FD"> <td>4</td> <td><input name="pg5" type="text" class="style17" id="pg5" tabindex="28" size="8"></td> <td><input name="pg5" type="text" class="style17" id="pg5" tabindex="28" size="8"></td> <td><input name="cd5" type="text" class="style17" id="cd5" tabindex="29" size="9"></td> <td><input name="desc5" type="text" class="style17" id="desc5" tabindex="30" size="12"></td> <td><input name="price5" type="text" class="style17" id="price5" tabindex="31" size="6"></td> <td><input name="qty5" type="text" class="style17" id="qty5" tabindex="32" size="3"></td> </tr> <tr bgcolor="#F5F4FD"> <td>5</td> <td><input name="pg6" type="text" class="style17" id="pg6" tabindex="33" size="8"></td> <td><input name="pg6" type="text" class="style17" id="pg6" tabindex="33" size="8"></td> <td><input name="cd6" type="text" class="style17" id="cd6" tabindex="34" size="9"></td> <td><input name="desc6" type="text" class="style17" id="desc6" tabindex="35" size="12"></td> <td><input name="price6" type="text" class="style17" id="price6" tabindex="36" size="6"></td> <td><input name="qty6" type="text" class="style17" id="qty6" tabindex="37" size="3"></td> </tr> <tr bgcolor="#F5F4FD"> <td>6</td> <td><input name="pg7" type="text" class="style17" id="pg7" tabindex="38" size="8"></td> <td><input name="pg7" type="text" class="style17" id="pg7" tabindex="38" size="8"></td> <td><input name="cd7" type="text" class="style17" id="cd7" tabindex="39" size="9"></td> <td><input name="desc7" type="text" class="style17" id="desc7" tabindex="40" size="12"></td> <td><input name="price7" type="text" class="style17" id="price172" tabindex="41" size="6"></td> <td><input name="qty7" type="text" class="style17" id="qty7" tabindex="42" size="3"></td> </tr> <tr bgcolor="#F5F4FD"> <td>7</td> <td><input name="pg8" type="text" class="style17" id="pg8" tabindex="43" size="8"></td> <td><input name="pg8" type="text" class="style17" id="pg8" tabindex="43" size="8"></td> <td><input name="cd8" type="text" class="style17" id="cd8" tabindex="44" size="9"></td> <td><input name="desc8" type="text" class="style17" id="desc8" tabindex="45" size="12"></td> <td><input name="price8" type="text" class="style17" id="price8" tabindex="46" size="6"></td> <td><input name="qty8" type="text" class="style17" id="qty8" tabindex="47" size="3"></td> </tr> <tr bgcolor="#F5F4FD"> <td>8</td> <td><input name="pg9" type="text" class="style17" id="pg9" tabindex="48" size="8"></td> <td><input name="pg9" type="text" class="style17" id="pg9" tabindex="48" size="8"></td> <td><input name="cd9" type="text" class="style17" id="cd9" tabindex="49" size="9"></td> <td><input name="desc9" type="text" class="style17" id="desc9" tabindex="50" size="12"></td> <td><input name="price9" type="text" class="style17" id="price9" tabindex="51" size="6"></td> <td><input name="qty9" type="text" class="style17" id="qty9" tabindex="52" size="3"></td> </tr> <tr bgcolor="#F5F4FD"> <td>9</td> <td><input name="pga" type="text" class="style17" id="pga" tabindex="53" size="8"></td> <td><input name="pga" type="text" class="style17" id="pga" tabindex="53" size="8"></td> <td><input name="cda" type="text" class="style17" id="cda" tabindex="54" size="9"></td> <td><input name="desca" type="text" class="style17" id="desca" tabindex="55" size="12"></td> <td><input name="pricea" type="text" class="style17" id="pricea" tabindex="56" size="6"></td> <td><input name="qtya" type="text" class="style17" id="qtya" tabindex="57" size="3"></td> </tr> <tr bgcolor="#F5F4FD"> <td>10</td> <td><input name="pgb" type="text" class="style17" id="pgb" tabindex="58" size="8"></td> <td><input name="pgb" type="text" class="style17" id="pgb" tabindex="58" size="8"></td> <td><input name="cdb" type="text" class="style17" id="cdb" tabindex="59" size="9"></td> <td><input name="descb" type="text" class="style17" id="descb" tabindex="60" size="12"></td> <td><input name="priceb" type="text" class="style17" id="priceb" tabindex="61" size="6"></td> <td><input name="qtyb" type="text" class="style17" id="qtyb" tabindex="62" size="3"></td> </tr> <tr bgcolor="#F5F4FD"> <td> </td> <td> </td> <td> </td> <td> </td> <td><div align="right">Total</div></td> <td><input name="pricec" type="text" class="style17" id="pricec" tabindex="66" size="6"></td> <td><input name="qtyc" type="text" class="style17" id="qtyc" tabindex="67" size="3"></td> </tr> <tr bgcolor="#3E55A7"> <td colspan="10" class="style9"> </td> </tr> <tr align="left" valign="top" bordercolor="#FFFFFF" bgcolor="#C7CFE9"> <td colspan="10" class="style10"><span class="style17">COMMENTS / DELIVERY INSTRUCTIONS: </span><br> <textarea name="comments" cols="30" rows="3" class="style17" id="comments"></textarea> <br></td> </tr> <tr bgcolor="#3E55A7"> <td colspan="10" class="style13"> </td> </tr> <tr bgcolor="#3E55A7"> <td colspan="10" class="style13"> </td> </tr> </table> <table width="80%" border="0"> <tr> <th scope="col"> </th> </tr> </table> <input type="SUBMIT" name="Submit" value="Submit Order"> Hi all i provided a little code to someone in the misc thread to block users based on the user agent language as an alternative to ipaddresses. I used switch for this but the each line is executed even if my language code is different. Anyone have an idea why the switch code below is messing with me? <?php if ( isset( $_SERVER["HTTP_ACCEPT_LANGUAGE"] ) ){ $languages = strtolower( $_SERVER["HTTP_ACCEPT_LANGUAGE"] ); // $languages = ' fr-ch;q=0.3, da, en-us;q=0.8, en;q=0.5, fr;q=0.3'; // need to remove spaces from strings to avoid error $languages = str_replace( ' ', '', $languages ); $languages = explode( ",", $languages ); // do something when you don't like the language switch ($languages[0]) { // first array item case 'ko': // korea echo "do something or set a variable"; break; case 'ru-md'||'ru': // russia echo "do something or set a variable"; break; case 'zh-cn'||'zh-hk'||'zh-mo'||'zh-sg'||'zh-tw'||'zh': // china echo "do something or set a variable"; break; case 'ne': // india echo "do something or set a variable"; break; default: echo "good"; } } ?> I changed it to a different code that uses in_array() which works, but i really would love to know why the above is not working as intended, i looked at php.net, but didn't found something nice in the comments. Maybe a guru out here that knows? <?php if ( isset( $_SERVER["HTTP_ACCEPT_LANGUAGE"] ) ){ $languages = strtolower( $_SERVER["HTTP_ACCEPT_LANGUAGE"] ); // $languages = ' fr-ch;q=0.3, da, en-us;q=0.8, en;q=0.5, fr;q=0.3'; // need to remove spaces from strings to avoid error $languages = str_replace( ' ', '', $languages ); $languages = explode( ",", $languages ); // do something when you don't like the language $lang_array = array('ko','ru-md','ru','zh-cn','zh-hk','zh-mo','zh-sg','zh-tw','zh','ne'); if (in_array($languages[0], $lang_array)){ echo 'bad stuff'; }else{ echo 'good stuff'; } } ?> Thanks guys!! I am working on a temporary mobile site while I try and fix my main site. As I do this, I am trying to look at better ways to code. Is there any problem/danger to including the HTML Head? Since this block of code repeats - except for the < title > - I figure why code it multiple times. I was thinking of using an INCLUDE on this...
<head> <!-- METADATA --> <meta charset="utf-8"> <meta name="viewport" content="width=device-width", height="device-height", initial-scale=1> <!-- TITLE --> <title>$title</title> <!-- STYLES --> <link type="text/css" rel="stylesheet" href="css/styles.css" /> </head>
Thoughts?
Are there any problems with calling an include file from within the <header> tags? The reason I'm asking is that I'm trying to load a speficied Style sheet based on a user's location and so I'm running a short script to determine which Style sheet needs to be displayed ... and that script is called from within the header tag. I haven't heard of any problems with doing this in the past, but the script seems to be generating an extra set of <HTML> tags in my source code and I can't figure out why this might be! Thanks, My website www.staceyxsolomon.com is only loading the header of my index.PHP page The full page is there i had double checke in the FTP It happened after my host put me onto another server, all settings carried over, please can somebody advise help if this is PHP related? Let's say I'm requesting a 5 megabyte data file with cURL. I want to echo it for the user as it gets downloaded with cURL. Is there any way to do this? I'm also just using cURL as an example, it could be file_get_contents(), or something else as well. Thanks! Code: [Select] <!-- The Input Form --> <form action="changemail_script.php" method="POST" > <input type="text" name="new_email" /> <input type="submit" name="submit_new_email" value="Submit" /> </form> When I have it as above, and I click submit, then the form loads the script itself and since the database connection variables are included into the header it will not work anymore. Any ideas why it does that? Should rather just include the script file and simply leave the action field empty, or do you have a better suggestion? Hi there, I have a HUGE list of inappropriate words in plain text, but the thing is, I want to use these bad words in an array. But I can't just copy and paste the bad words into the array, as each bad word needs to have two apostraphes aside one another. E.g the array should be: Code: [Select] $bad_words = array('badword1','badword2','badword3'); but my text document just has: badword1 badword2 badword3 How do I format the bad words to have apostraphes aside each other? I don't want to manually go through each word. Thanks Heya guys The other day i got the error: [28-Jan-2011 12:07:40] PHP Warning: POST Content-Length of 16970062 bytes exceeds the limit of 8388608 bytes in Unknown on line 0 Basically this means my server provider doesn't allow the total $_POST data on one page to be above 8MB, and being on shared hosting i cannot fix this So, whats the best way to get around this? Ajax? Options and code samples please I think this will help a lot of people as i haven't seen many answers after lots of research on the web. Thanks Danny. This is my code [Page where user uploads files -Edit-Page.php] <?php session_start(); if ($_SESSION['adminlogin'] == 1){ //Run } else { header('Location: Log-In.php'); exit; } $url = $_POST['url']; ?> <!DOCTYPE HTML> <html lang="en-GB"> <head> <meta charset="utf-8"> <!--Search Engine Meta Tags--> <meta name="author" content="Worldwide Lighthouses"> <meta name="keywords" content="Lighthouses,Lightships,Trinity House,Fog Signals,Fog Horns,Fresnel"> <meta name="description" content="Worldwide Lighthouses is the number 1 source of information, pictures and videos on the Subject of Lighthouses and Lightships"> <!--Stylesheets/Javascript--> <link rel="stylesheet" href="../../Page-Layout.css" media="screen and (min-width: 481px)"> <link rel="stylesheet" href="../../Mobile-Page-Layout.css" media="only screen and (max-width:480px)"> <!--Mobile Browser Support--> <meta name="viewport" content="width=320; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;"> <!--IE Support--> <!--[if lt IE 9]><script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script> <link rel="stylesheet" href="../Page-Layout.css"><![endif]--> <meta name="application-name" content="Worldwide Lighthouses"> <meta name="msapplication-starturl" content="http://worldwidelighthouses.com/"> <meta name="msapplication-tooltip" content="Worldwide Lighthouses: Your number one source of Lighthouse Information, Videos and Pictures"> <meta name="msapplication-task" content="name=Lighthouses;action-uri=http://worldwidelighthouses.com/Lighthouses.php;icon-uri=http://worldwidelighthouses.com/IE9/Lighthouses.ico"> <meta name="msapplication-task" content="name=Lightships;action-uri=http://worldwidelighthouses.com/Lightships.php;icon-uri=http://worldwidelighthouses.com/IE9/Lightships.ico"> <meta name="msapplication-task" content="name=Fog Signals;action-uri=http://worldwidelighthouses.com/Fog-Signals.php;icon-uri=http://worldwidelighthouses.com/IE9/Fog-Signals.ico"> <meta name="msapplication-task" content="name=Glossary;action-uri=http://worldwidelighthouses.com/Glossary.php;icon-uri=http://worldwidelighthouses.com/IE9/Glossary.ico"> <title>Edit Page | Worldwide Lighthouses</title> <script> <!-- function fixForm(select) { var inputCount = parseInt(select); var newHTML = ''; for(i=1; i<=inputCount; i++) { newHTML += '<label>Thumbnail '+i+' | Size: 200px x 430px | Format: PNG</label>\n'+ '<input type="file" name="thumbnail'+i+'" size="100" accept="image/x-png" class="File">\n'+ '<label>Accompanying Large Image | Size : Large | Format: PNG</label>\n'+ '<input type="file" name="large'+i+'" size="100000000" accept="image/x-png" class="File"><br><br>\n' ; if(i < inputCount) { newHTML += '<br>\n\n'; } else { newHTML += '\n\n'; } } document.getElementById('formInputs').innerHTML=newHTML; } //--> function setVisibility(id, visibility) { document.getElementById(id).style.display = visibility; } </script> <style> input:focus, textarea:focus { background:#9CDCCB; } form#Page { width:80%; margin-top:10px; margin-bottom:10px; margin-left:auto; margin-right:auto; background-colour: rgb(33, 33, 33); /* The Fallback */ background: rgba(33, 33, 33, 0.8); border-radius:10px; padding:20px; } label { display:block; width:100%; color:#FFF; } .TitleInput { width:660px; } .info { width:260px; height:80px; } .url { width:660px; } #IntroParagraph{ width:660px; height:120px; } #MainParagraph{ width:660px; height:240px; } .File { width:660px; } #loading { position: fixed; top: 25%; left: 25%; width: 50%; height: 50%; background:url(../../layout-resources/article-background.jpg); border:3px #333 solid; border-radius:10px; text-align:center; color:#1D5A4B; display:none; } #loadinginfo { position: absolute; top: 25%; left: 25%; width: 50%; height: 50%; } </style> </head> <body> <div id="loading"><div id="loadinginfo"><img src="upload.gif" width="128" height="15" alt="Uploading"><br><h1>Uploading images...</h1><p>Please Wait, this could take a while.</p></div></div> <header> <h1 id="WWLH">Worldwide Lighthouses</h1> <form method="get" action="http://www.worldwidelighthouses.com/Search/search.php" id="Search-Box"> <input type="search" placeholder="Search Worldwide Lighthouses" name="query" id="query" size="30" value="" autocomplete="off"> <input type="submit" value="Search"> <input type="hidden" name="search" value="1"> </form> </header> <nav> <ul id="Nav"> <li class="MenuButton" id="Index"><a href="http://www.worldwidelighthouses.com/Index.php"><p class="Nav">Home</p></a></li> <li class="MenuButton" id="Lighthouses"><a href="http://www.worldwidelighthouses.com/Lighthouses.php"><p class="Nav">Lighthouses</p></a></li> <li class="MenuButton" id="Lightships"><a href="http://www.worldwidelighthouses.com/Lightships.php"><p class="Nav">Lightships</p></a></li> <li class="MenuButton" id="FogSignals"><a href="http://www.worldwidelighthouses.com/Fog-Signals.php"><p class="Nav">Fog Signals</p></a></li> <li class="MenuButton" id="Daymarks"><a href="http://www.worldwidelighthouses.com/Daymarks.php"><p class="Nav">Daymarks</p></a></li> <li class="MenuButton" id="Buoys"><a href="http://www.worldwidelighthouses.com/Buoys.php"><p class="Nav">Buoys</p></a></li> <li id="MenuButtonLast"><a href="http://www.worldwidelighthouses.com/Glossary.php"><p class="Nav">Glossary</p></a></li> </ul> </nav> <?php if ($_SESSION['adminlogin']==1) { echo '<div id="logout"> <div style="float:left; width:30%; text-align:left;!important"> <a href="Log-In-Accept-Deny.php">Back to Admin Home</a> </div> <div style="float:right; width:70%;"> <a href="Logout.php">Log Out of Admin</a> <p style="font-size:10px;">Always Sign Out when Finished!</p> </div></div>';} ?> <article> <h1 class="Title">Enter Page Information</h1> <div class="Textbox"> <form action="Preview-and-Confirm-Page-Changes.php" enctype="multipart/form-data" method="post" id="Page"> <input type="hidden" value="<?php echo $url ?>" name="url"> <label>Type of Page</label> <br> <input type="radio" name="typeofpage" value="englandtrinityhouse" checked> English - Trinity House <br> <input type="radio" name="typeofpage" value="englandprivate"> English - Privately Owned <br> <input type="radio" name="typeofpage" value="welshtrinityhouse"> Welsh - Trinity House <br> <input type="radio" name="typeofpage" value="welshprivate"> Welsh - Privately Owned <br> <input type="radio" name="typeofpage" value="northernlighthouseboard"> Scottish - Northern Lighthouse Board <br> <input type="radio" name="typeofpage" value="scottishprivate"> Scottish - Privately Owned <br> <input type="radio" name="typeofpage" value="channelislandstrinityhouse"> Channel Islands - Trinity House <br> <input type="radio" name="typeofpage" value="channelislandsprivate"> Channel Islands - Privately Owned <br> <input type="radio" name="typeofpage" value="francelb"> French - Lighthouse Board <br> <input type="radio" name="typeofpage" value="franceprivate"> French - Privately Owned <br> <input type="radio" name="typeofpage" value="switzerland"> Switzerland <br> <input type="radio" name="typeofpage" value="norway"> Norway <br> <input type="radio" name="typeofpage" value="lightshiptrinityhouse"> Lightship - Trinity House <br> <input type="radio" name="typeofpage" value="lightshipprivate"> Lightship - Private <br> <br> <label>Folder Name (Usually title of page with hyphens eg. Beachy-Head) Just provide the last section</label> <input type="text" name="foldername"> <label>Title of Page<br>(eg.Beachy Head Lighthouse. Dont Include | Worldwide Lighthouses, this is automatically added)</label><input type="text" placeholder="Title of Page" name="title" class="TitleInput"><br><br> <input type="hidden" name="MAX_FILE_SIZE" value="100000000000000000000000000000" /> <label>Main Page Image | Size: 170x170px Format:PNG</label><input type="file" name="mainpageimage" size="100" accept="image/x-png" class="File"><br><br> <h2>Information</h2> <label>Date Established:</label><input type="text" placeholder="Date Established" name="established" required="true" class="TitleInput"><br> <label>Current Lighthouse Built:</label><input type="text" placeholder="Date Current Lighthouse Established" name="currentlighthousebuilt" required="true" class="TitleInput"><br> <label>Height (In Metres, Will automatically convert to show feet and metres on same page)</label><input type="number" placeholder="Heigtht in metres" name="height" required="true" class="TitleInput"><br> <label>Date Automated:</label><input type="text" placeholder="Date Automated" name="automated" required="true" class="TitleInput"><br> <label>Date Electrified:</label><input type="text" placeholder="Date Electrified" name="electrified" required="true" class="TitleInput"><br> <label>Range (In Nautical Miles):</label><input type="number" placeholder="Range in Nautical Miles" name="range" required="true" class="TitleInput"><br> <label>Operator:</label><input type="text" placeholder="Operator" name="operator" required="true" class="TitleInput"><br><br> <h2>Media</h2> <label>Link to Video Page: (if none leave blank)</label><input type="url" name="video"> <label>Link to Audio Page: (if none leave blank)</label><input type="url" name="audio"> <h2>Write up</h2> <label>Paragraph:</label><textarea id="MainParagraph" name="paragraph"></textarea> <h2>Thumbnails</h2> <label> Number of Thumbnails </label> <select name="numberofthumbnails" onChange="fixForm(this.options[selectedIndex].text);"> <option value="0">0</option> <option value="2">2</option> <option value="4">4</option> <option value="6">6</option> <option value="8">8</option> <option value="10">10</option> <option value="12">12</option> <option value="14">14</option> <option value="16">16</option> <option value="18">18</option> <option value="20">20</option> <option value="22">22</option> <option value="24">24</option> </select> <br><br> <span id="formInputs"> </span> <input type="submit" value="Preview Page" onClick="setVisibility('loading', 'block');"> </form> <?php if ($_SESSION['adminlogin'] == 1){ echo "<br>Logged in on server side."; }?> </div> </article> <footer> <ul> <li><a href="http://www.worldwidelighthouses.com/About.php">About</a></li> <li><a href="http://www.worldwidelighthouses.com/Contact-us.php">Contact</a></li> <li><a href="http://www.worldwidelighthouses.com/Use-Our-Media.php">Use our media</a></li> <li><a href="http://www.worldwidelighthouses.com/Search/search.php">Search</a></li> <li><a href="http://www.worldwidelighthouses.com/Social-Networking.php">Social</a></li> <li><a href="#Top">Back to top</a></li> </ul> <br> <br> &#169; Worldwide Lighthouses <?php echo date("Y"); ?> </footer> </body> Hey everyone, have taken a bit of a break (a couple of years) from all things PHP and generally web related, but now a project has popped up that I am really interested in figuring out. I am so, so sorry if this ends up being a very long and confusing post, but I am really hoping somebody out there might have some experience in doing this sort of thing, or maybe it is just MUCH simpler than I have convinced myself of, and I am making things unnecessarily hard for myself. First of all, I am not sure if this is as much of a coding question, or if I am just not managing to sort out the logic of it all in my head, but for some reason I just cant figure out where to get started. I am not looking for someone to tell me what to write per say, but just any advice at all that can head me in the right direction. Anyhow, here goes.. I have an automatically generated roster file, created by sabre airline solutions, that is automatically emailed out to all employees of the airline. It is a 28 day roster, and I am wanting to write a script of some sort that will automatically convert it into an ICS or Ical file for further integration with things I am doing. I have done a lot of reading about the formats of ics files, and I understand how they work, it is just writing something that will interpret the initial roster correctly that is stumping me, once I get the information out of it in a logical way, I think I can easily turn it into an ics. I was heading down the array pathway before, but I just keep getting to dead ends and methods that just arent practical. Here is a snippit from the original roster format: "31 AKL7494 LO APW 1250 APW 1210* - APW 23:20 0450 0620 01 AKL7494 0630 0091 AKL 0730 APW 1220- 03:50 24:50 73P AKL7494 1210 0094 APW 1310 AKL 1615* 04:05 00:30 73P 02 AKL7494 RST AKL 1645 AKL 0445* - AKL 0405 0535 34:15 12:00 03 AKL7506 0500 GT AKL 0500 HLZ 0700 02:00 - AKL7506 0085 HLZ 0800 BNE 0840 03:40 00:30 73P AKL7506 LO BNE 0910 BNE 0830* - BNE 23:20 0340 0710 04 AKL7506 0830 0074 BNE 0930 DUD 1610 03:40 00:50 73P AKL7506 0075 DUD 1700 BNE 1745 03:45 00:30 73P AKL7506 LO BNE 1815 BNE 1430* - BNE 20:15 0725 0945 05 AKL7506 LO APW 0050 APW 1210 - APW 11:20 0725 0945 AKL7506 1210 0094 APW 1310 AKL 1615* 04:05 -21:-4573P AKL7506 1430 0097 BNE 1530 APW 0020 04:50 17:25 73P 06 AKL7506 RST AKL 1645 AKL 0445* - AKL 0450 0620 83:45 12:00 " if a little clarification is needed.. (i know I needed it when I first began recieving these rosters!) the 31, 01, 02 etc are the dates of the month, the 31 only comes up if the month before ends halfway through a trip where the person is still away for work when the month turns over. the AKL,APW,BNE etc are airport/location codes, LO is layover (eg spending the night there) the other various times are departure times, arrival times (all in local time to wherever the person happens to be at the time) and also flight times, total duty times. The airport codes with numbers (eg AKL7506) is the trip code, meaning for that whole period you will be with the same crew, and away from your home port/base. The first problem I have encountered, is it is not consistent, some days will have 1 line, but layovers will take up one or two or more lines, so I cannot just separate the entries via line, i guess it has to be started wherever a numerical/date value begins the line? Also how do i split the data, based on white space in between (if that makes sense) I hope maybe this makes a little sense to someone, I know somebody has managed to write exactly what I am trying to do, for the exact same roster system, but for a different purpose, but I have had no luck getting in touch with this person. Thanks so much to anyone who can shed any light on this situation, Anna I've been trying to wrap my head around this for about two hours now. The file uploads just fine, the entry goes into the database just fine, EXCEPT for the file name like it's supposed to do. I wrote the code from scratch... it worked fine, then it broke (that's the way it's supposed to work, right?) Anyways, if anyone could take a look-see and point out what I'm missing? I've tried throwing errors on all the queries, I've made sure the filename is passed from the upload form, the form does have the proper enctype. require 'dbconfig.php'; $title = escape($_POST['title']); $content= escape($_POST['content']); $time = time(); //Check the file. if (!empty($_FILES['attachment'])) { //$filename = the name as saved on user's the computer. //$filename = $_FILES['attachment']['name']; if($_FILES['attachment']['type'] === 'image/jpeg' || $_FILES['attachment']['type'] === 'image/jpg' || $_FILES['attachment']['type'] === 'application/pdf') { //Move the file only if it's uploaded. if (is_uploaded_file($_FILES['attachment']['tmp_name'])) { //Whoops, an error. if (!move_uploaded_file($_FILES['attachment']['tmp_name'], './attachments/' . $_FILES['attachment']['name'])) { die('Error: File not uploaded. Please make sure it is a JPEG image or a PDF document.'); } else { $filename = $_FILES['attachment']['name']; } } } } if( $filename = '' || empty($_FILES['attachment'] )) { die('No attachment found. Please <a href="javascript: history.go(-1)">Go back</a>'); } if ($title === '') { die('News title is empty. Please <a href="javascript: history.go(-1)">Go back</a>'); } if ($content === '') { die('News content is empty. Please <a href="javascript: history.go(-1)">Go back</a>'); } else { if (mysql_query("INSERT INTO news (news_title, news_content, news_posted, news_edited, news_attach_path) VALUES ('$title', '$content', '$time', '0', '$filename')") or die(mysql_error())) { $posted = true; } else { $posted = false; } } ?> For eg. I would prefer to have a link like this in the head section.
<head> <script src="js/code.js"></script> </head>as oppose to like this. <head> <script> var _debug = false; var _placeholderSupport = function() { var t = document.createElement("input"); t.type = "text"; return (typeof t.placeholder !== "undefined"); }(); window.onload = function() { var arrInputs = document.getElementsByTagName("input"); var arrTextareas = document.getElementsByTagName("textarea"); var combinedArray = []; for (var i = 0; i < arrInputs.length; i++) combinedArray.push(arrInputs[i]); for (var i = 0; i < arrTextareas.length; i++) combinedArray.push(arrTextareas[i]); for (var i = 0; i < combinedArray.length; i++) { var curInput = combinedArray[i]; if (!curInput.type || curInput.type == "" || curInput.type == "text" || curInput.type == "textarea") HandlePlaceholder(curInput); else if (curInput.type == "password") ReplaceWithText(curInput); } if (!_placeholderSupport) { for (var i = 0; i < document.forms.length; i++) { var oForm = document.forms[i]; if (oForm.attachEvent) { oForm.attachEvent("onsubmit", function() { PlaceholderFormSubmit(oForm); }); } else if (oForm.addEventListener) oForm.addEventListener("submit", function() { PlaceholderFormSubmit(oForm); }, false); } } }; function PlaceholderFormSubmit(oForm) { for (var i = 0; i < oForm.elements.length; i++) { var curElement = oForm.elements[i]; HandlePlaceholderItemSubmit(curElement); } } function HandlePlaceholderItemSubmit(element) { if (element.name) { var curPlaceholder = element.getAttribute("placeholder"); if (curPlaceholder && curPlaceholder.length > 0 && element.value === curPlaceholder) { element.value = ""; window.setTimeout(function() { element.value = curPlaceholder; }, 100); } } } function ReplaceWithText(oPasswordTextbox) { if (_placeholderSupport) return; var oTextbox = document.createElement("input"); oTextbox.type = "text"; oTextbox.id = oPasswordTextbox.id; oTextbox.name = oPasswordTextbox.name; //oTextbox.style = oPasswordTextbox.style; oTextbox.className = oPasswordTextbox.className; for (var i = 0; i < oPasswordTextbox.attributes.length; i++) { var curName = oPasswordTextbox.attributes.item(i).nodeName; var curValue = oPasswordTextbox.attributes.item(i).nodeValue; if (curName !== "type" && curName !== "name") { oTextbox.setAttribute(curName, curValue); } } oTextbox.originalTextbox = oPasswordTextbox; oPasswordTextbox.parentNode.replaceChild(oTextbox, oPasswordTextbox); HandlePlaceholder(oTextbox); if (!_placeholderSupport) { oPasswordTextbox.onblur = function() { if (this.dummyTextbox && this.value.length === 0) { this.parentNode.replaceChild(this.dummyTextbox, this); } }; } } function HandlePlaceholder(oTextbox) { if (!_placeholderSupport) { var curPlaceholder = oTextbox.getAttribute("placeholder"); if (curPlaceholder && curPlaceholder.length > 0) { Debug("Placeholder found for input box '" + oTextbox.name + "': " + curPlaceholder); oTextbox.value = curPlaceholder; oTextbox.setAttribute("old_color", oTextbox.style.color); oTextbox.style.color = "#c0c0c0"; oTextbox.onfocus = function() { var _this = this; if (this.originalTextbox) { _this = this.originalTextbox; _this.dummyTextbox = this; this.parentNode.replaceChild(this.originalTextbox, this); _this.focus(); } Debug("input box '" + _this.name + "' focus"); _this.style.color = _this.getAttribute("old_color"); if (_this.value === curPlaceholder) _this.value = ""; }; oTextbox.onblur = function() { var _this = this; Debug("input box '" + _this.name + "' blur"); if (_this.value === "") { _this.style.color = "#c0c0c0"; _this.value = curPlaceholder; } }; } else { Debug("input box '" + oTextbox.name + "' does not have placeholder attribute"); } } else { Debug("browser has native support for placeholder"); } } function Debug(msg) { if (typeof _debug !== "undefined" && _debug) { var oConsole = document.getElementById("Console"); if (!oConsole) { oConsole = document.createElement("div"); oConsole.id = "Console"; document.body.appendChild(oConsole); } oConsole.innerHTML += msg + "<br />"; } } </script> </head>How can I make that happen? I rather not show that awful long code in the head. |