Jump to content

nepzap2

Members
  • Posts

    70
  • Joined

  • Last visited

    Never

Everything posted by nepzap2

  1. Would passing values using the POST method require using a form?
  2. Yes, that is correct. I will try this approach and get back to this post with the answer. Thank you for pointing me in the right direction.
  3. Thanks for the quick reply phpORcaffine, Do you know of a way to resolve this issue? Thanks.
  4. Dear All, I wanted to know why the following syntax does not work when targeting an anchor index.php?page=TechnologyTransferTest&section=BTI-TN5B1#ntro Bu this one does BTI-TN5B1.php#ntro Can anyone help?
  5. Hello AyKay47, Thank you. Removing the ";" from ";date.timezone = "America/New_York"" solved the problem.
  6. Thanks AyKay47 Below are my settings [Date] ; Defines the default timezone used by the date functions ; http://php.net/date.timezone ;date.timezone = ; http://php.net/date.default-latitude ;date.default_latitude = 31.7667 ; http://php.net/date.default-longitude ;date.default_longitude = 35.2333 ; http://php.net/date.sunrise-zenith ;date.sunrise_zenith = 90.583333 ; http://php.net/date.sunset-zenith ;date.sunset_zenith = 90.583333 [filter] ; http://php.net/filter.default ;filter.default = unsafe_raw ; http://php.net/filter.default-flags ;filter.default_flags =
  7. Hello everyone, I updated my version of php and since, a piece of code that always seemed to work no spits out the following Warning: Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/New_York' for '-5.0/no DST' instead in C:\Abyss Web Server\htdocs\bti.cornell.edu\includes\home_news.php on line 13 The simple code was the following: <?php $currYear = date("Y"); echo "<li><a href='index.php?page=NewsArchive&year=$currYear' class='moreInformation'>News Archive</a></li>"; ?>
  8. Thank you guys. This helps.
  9. Thanks, I understand the logic. How would I define a variable that I'm passing via the $_GET method. For instance in this situation.
  10. line 25 reads switch (htmlentities ($_GET['page'])){
  11. Devotee, Thank you for answering. The code is the following: <?php //error_reporting (E_ALL ^ E_NOTICE); //error_reporting(0); //session_start(); include "functions/functions.php"; // Testing News Functions // include "functions/functionsAllSummerInterns.php"; include "functions/functionsNews.php"; include "includes/header.php"; ini_set('arg_separator.output', '&'); /* Below are the cases for each section of the website. Through the $_GET[''] Method we detect which section the user clicks on and style the section accordingly. */ // Body Content Begins switch (htmlentities ($_GET['page'])){ More Code ?>
  12. Dear all, I updated my versions of php/MySQL and OS to Windows 7 Professional and weird "Warnings and Notices:" started popping up. E.g. "Notice: Undefined index: page in C:\Server\htdocs\domain\index.php on line 25 " Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/New_York' for '-4.0/DST' instead in C:\Server\htdocs\domain\index.php on line 12 " I don't know what is going on. Unless I enter these following functions (error_reporting(0);, session_start() with their parameters these warnings display. Can anyone offer any advice? Any assistance is appreciated.
  13. Hello kenrbnsn, Thanks for answering. Yes I do. I use it in my json_proxy file that handles the querying for my search. Below is the code. I had commented out the "session_start();" but that did not do anything. <?php /* We wanna have sessions enabled for json/ajax because we might in the future add authentication and session tracking so that only authorized users can get JSON data. */ session_start(); /* The usual connect stuff. This should come from a single include that other scripts share, but for now we'll just put it here. */ $conn = mysql_pconnect("myhost", "username", "password") or trigger_error(mysql_error(),E_USER_ERROR); mysql_select_db ("someDatabse") or die ("I cannot select the database '$dbname' because: " . mysql_error()); /* Lookup function for staff. It uses a single lookup parameter which comes from a text box in the browser. This means that it could contain one or two words (first name and last name) in any order. We'll ignore any characters (a ',' for example) which are not letters. */ function getStaffInfo($term){ if(null == $term) return null; //trim $term to remove leading and ending spaces, and return null if $term is empty $term = trim($term); if("" === $term) return null; //replace any non-alphabetic characters with spaces $term = ereg_replace("[^A-Za-z]", " ", $term); /* At this point $term should have one or more values (first/last): $term = "Brutnell" $term = "Rosero Camilo" or "Camilo Rosero" It could happen that there are multiple spaces in the case of two values (first/last names), so lets ereg_replace for that case */ $term = ereg_replace(" +", " ", $term); //convert all characters to UPPER CASE to make comparison with database values easier $term = strtoupper($term); //if $term has two values, then the following will return an array of length greater than 1 $term_array = explode(" ", $term); //our $sql statement will basically compare the values in the array with the first and last //names in staff_contact_table (in upper case), in any order, to make sure we catch all our //cases $where_clause = "WHERE "; if(1 == count($term_array)){ $where_clause .= "UPPER(first_name) LIKE '" . $term_array[0] . "%' OR UPPER(last_name) LIKE '" . $term_array[0] . "%' OR UPPER(title) LIKE '%" . $term_array[0] . "%' OR UPPER(title) LIKE '%" . $term_array[0] . "%'"; }else{ $where_clause .= "(UPPER(first_name) LIKE '" . $term_array[0] . "%' AND UPPER(last_name) LIKE '" . $term_array[1] . "%') OR (UPPER(first_name) LIKE '" . $term_array[1] . "%' AND UPPER(last_name) LIKE '" . $term_array[0] . "%') OR UPPER(title) LIKE '%" . $term_array[0] . "%' OR UPPER(title) LIKE '%" . $term_array[1] . "%' OR UPPER(category) LIKE '%" . $term_array[0] . "%' OR UPPER(category) LIKE '%" . $term_array[1] . "%'"; } $sql = "SELECT * FROM staff_contact_table $where_clause ORDER BY last_name ASC"; $result = mysql_query($sql); return $result; } //Ths simple function returns a parameter from either $_GET or $_POST, checking in $_GET first function getParam($name){ $ret = $_GET[$name]; if(null == $ret || "" === trim($ret)){ $ret = $_POST[$name]; } if(null == $ret || "" === trim($ret)){ return null; } return $ret; } header('Cache-Control: no-cache, must-revalidate'); header('Content-type: application/json'); $function = getParam("function"); $jsoncallback = getParam("jsoncallback"); if("getcontactJSON" === $function){ } else if("getcontacthtml" === $function){ $searchterm = getParam("searchterm"); $staffdata = getStaffInfo($searchterm); if(null == $staffdata){ return "$jsoncallback({'error':'no data', 'searchterm':" . json_encode($searchterm) . "})"; } else{ $html = ""; while($row = mysql_fetch_assoc($staffdata)){ $workgroup = $row['work_group']; $html .= "<div style=''>" . "<div style='float: left; width: 175px;'>" . "<img src='images/lab_members_images/$workgroup/" . $row['image_name'] . "'>" . "</div>" . "<div style='float: left; width: 175px;'>" . $row['first_name'] . " " . $row['last_name'] . "<br />" . $row['title'] . "</div>" . "</div>" . "<div style='clear: both;'></div>"; } echo "$jsoncallback({'html':" . json_encode($html) . ", 'searchterm':" . json_encode($searchterm) . "});"; } } ?> <?php function json_encode($a=false) { if (is_null($a)) return 'null'; if ($a === false) return 'false'; if ($a === true) return 'true'; if (is_scalar($a)) { if (is_float($a)) { // Always use "." for floats. return floatval(str_replace(",", ".", strval($a))); } if (is_string($a)) { static $jsonReplaces = array(array("\\", "/", "\n", "\t", "\r", "\b", "\f", '"'), array('\\\\', '\\/', '\\n', '\\t', '\\r', '\\b', '\\f', '\"')); return '"' . str_replace($jsonReplaces[0], $jsonReplaces[1], $a) . '"'; } else return $a; } $isList = true; for ($i = 0, reset($a); $i < count($a); $i++, next($a)) { if (key($a) !== $i) { $isList = false; break; } } $result = array(); if ($isList) { foreach ($a as $v) $result[] = json_encode($v); return '[' . join(',', $result) . ']'; } else { foreach ($a as $k => $v) $result[] = json_encode($k).':'.json_encode($v); return '{' . join(',', $result) . '}'; } } ?>
  14. Thanks for replying Karl. O.K. Below you should find my menu which I include in my header which I then include in my control page. The control page includes a functions page. <div class="megaMenuHover"> <a href="./" class="megaMenuHover">Home</a> <a href="home.php?page=AboutUs&section=AboutBTI" id="megaanchor" class="megaMenuHover" <?php testPage("AboutUs"); ?>>About BTI</a> <!--Mega Menu Anchor--> <a href="home.php?page=Research" id="megaanchor2" class="megaMenuHover" <?php testPage("Research"); ?>>Research</a> <a href="home.php?page=Education&section=EducationOverview" id="megaanchor3" class="megaMenuHover" <?php testPage("Education"); ?>>Education and Outreach</a> <a href="home.php?page=Environment" class="megaMenuHover" <?php testPage("Environment"); ?>>Environment</a> <a href="home.php?page=Employment&section=EmploymentOverview" id="megaanchor4" class="megaMenuHover" <?php testPage("Employment"); ?>>Employment</a> <a href="home.php?page=Contact&section=Overview" id="megaanchor5" class="megaMenuHover" <?php testPage("Contact"); ?>>Contact</a> </div> <!--Mega Drop Down Menu HTML. Retain given CSS classes--> <div id="megamenu1" class="megamenu"> <div class="column"> <ul> <li><a href="home.php?page=AboutUs&section=OurMission" class="subMenuLink">Our Mission</a></li> <li><a href="home.php?page=AboutUs&section=OurMission#OurVision" class="subMenuLink">Our Vision</a></li> <li><a href="home.php?page=AboutUs&section=FromthePresident" class="subMenuLink">From the President</a></li> <li><a href="home.php?page=AboutUs&section=OurBoardofDirectors" class="subMenuLink">Our Board of Directors</a></li> <li><a href="home.php?page=AboutUs&section=Ethics" class="subMenuLink">Ethics</a></li> <li><a href="home.php?page=AboutUs&section=History" class="subMenuLink">History</a></li> <li><a href="home.php?page=AboutUs&section=Periodicals" class="subMenuLink">Periodicals</a></li> </ul> </div> </div> <!--Mega Drop Down Menu HTML. Retain given CSS classes--> <div id="megamenu2" class="megamenu"> <div class="column"> <ul> <li><a href="" style="color: #5d829d; font-weight: bold; text-decoration: none;">Research Overview</a></li> <li><a href="home.php?page=Research&section=PGS" class="subMenuLink">Post-Graduate Society</a></li> <li><a href="home.php?page=Research&section=LicensingOverview" class="subMenuLink">Licensing</a></li> <li><a href="home.php?page=Research&section=listpubs" class="subMenuLink">Published Articles</a></li> <li><a href="home.php?page=Research&section=SeminarsAtBTI" class="subMenuLink">Seminars at BTI</a></li> <li><a href="home.php?page=Research&section=Resources" class="subMenuLink2">Resources</a></li> <li><a href="" style="color: #5d829d; font-weight: bold; text-decoration: none;">Facilities & Services</a></li> <li><a href="home.php?page=Research&section=FacilitiesServices" class="subMenuLink">Overview</a></li> <li><a href="home.php?page=Research&section=FacilitiesServices&subsection=Auditorium" class="subMenuLink">Auditorium</a></li> <li><a href="home.php?page=Research&section=FacilitiesServices&subsection=BiotechnologyCenter" class="subMenuLink">Biotechnology Center</a></li> <li><a href="home.php?page=Research&section=FacilitiesServices&subsection=InformationResourceCenter" class="subMenuLink">Information Resource Center</a></li> <li><a href="home.php?page=Research&section=FacilitiesServices&subsection=PlantCellImagingCenter" class="subMenuLink">Plant Cell Imaging Center</a></li> <li><a href="home.php?page=Research&section=FacilitiesServices&subsection=PlantGrowthFacility" class="subMenuLink">Plant Growth Facility</a></li> </ul> </div> <div class="column"> <ul> <li><a href="" style="color: #5d829d; font-weight: bold; text-decoration: none;">Research Overview</a></li> <li><a href="home.php?page=Research&section=FacultyOverview" class="subMenuLink">Overview</a></li> <li><a href="KlausApel.php?page=Research" class="subMenuLink">Klaus Apel</a></li> <li><a href="GaryBlissard.php?page=Research" class="subMenuLink">Gary Blissard</a></li> <li><a href="TomBrutnell.php?page=Research" class="subMenuLink">Tom Brutnell</a></li> <li><a href="CarmenCatala.php?page=Research" class="subMenuLink">Carmen Catala</a></li> <li><a href="ZhangjunFei.php?page=Research" class="subMenuLink">Zhangjun Fei</a></li> <li><a href="JimGiovannoni.php?page=Research" class="subMenuLink">Jim Giovannoni</a></li> <li><a href="MariaHarrison.php?page=Research" class="subMenuLink">Maria Harrison</a></li> <li><a href="GeorgJander.php?page=Research" class="subMenuLink">Georg Jander</a></li> <li><a href="DanKlessig.php?page=Research" class="subMenuLink">Dan Klessig</a></li> <li><a href="Ji-YoungLee.php?page=Research" class="subMenuLink">Ji-Young Lee</a></li> <li><a href="GregoryMartin.php?page=Research" class="subMenuLink">Gregory Martin</a></li> <li><a href="LukasMueller.php?page=Research" class="subMenuLink">Lukas Mueller</a></li> <li><a href="SorinaPopescu.php?page=Research" class="subMenuLink">Sorina Popescu</a></li> <li><a href="EricRichards.php?page=Research" class="subMenuLink">Eric Richards</a></li> <li><a href="FrankSchroeder.php?page=Research" class="subMenuLink">Frank Schroeder</a></li> <li><a href="DavidStern.php?page=Research" class="subMenuLink">David Stern</a></li> <li><a href="JoyceVanEck.php?page=Research" class="subMenuLink">Joyce Van Eck</a></li> <li><a href="home.php?page=Research&section=EmeritusScientists" class="subMenuLink">Emeritus Scientists</a></li> <li><a href="home.php?page=Research&section=AdjunctScientists" class="subMenuLink">Adjunct Scientists</a></li> </ul> </div> <br style="clear: left" /> <!--Break after 3rd column. Move this if desired--> </div> <!--Mega Drop Down Menu HTML. Retain given CSS classes--> <div id="megamenu3" class="megamenu"> <div class="column"> <ul> <li> <a href="home.php?page=Education&section=EducationOverview" style="color: #5d829d; font-weight: bold; text-decoration: none;"> Education Overview</a> </li> <li><a href="home.php?page=Education&section=TeacherPrograms" class="subMenuLink">Teacher Program</a></li> <li><a href="home.php?page=Education&section=EducationResources" class="subMenuLink">Educational Resources</a></li> <li><a href="mailto:pgrp-outreach@cornell.edu" class="subMenuLink">Contact Us</a></li> </ul> </div> <div class="column"> <ul> <li> <a href="home.php?page=Education&section=Internships#page=PGRPSummerInternships" style="color: #5d829d; font-weight: bold; text-decoration: none;">Internships Overview</a> </li> <li><a href="home.php?page=Education&section=Internships#page=FAQ" class="subMenuLink">FAQ</a></li> <li><a href="home.php?page=Education&section=Internships#page=PGRPSummerInternships" class="subMenuLink">PGRP Summer Internships</a></li> <li><a href="home.php?page=Education&section=Internships#page=PGRPFacultyResearch" class="subMenuLink">PGRP Faculty Research</a></li> <li><a href="home.php?page=Education&section=Internships#page=ApplyingInternship" class="subMenuLink">Applying for an Intership</a></li> <li><a href="pdfs/Recommendationform_10.pdf" class="subMenuLink">Recommendation Form</a></li> </ul> </div> <br style="clear: left" /> <!--Break after 3rd column. Move this if desired--> </div> <!--Mega Drop Down Menu HTML. Retain given CSS classes--> <div id="megamenu4" class="megamenu"> <div class="column"> <ul> <li> <a href="home.php?page=Employment&section=EmploymentOverview" style="color: #5d829d; font-weight: bold; text-decoration: none;"> Job Openings</a></li> <li><a href="http://www.bti.cornell.edu/pdfs/hr/hrforms/application_form.pdf" class="subMenuLink">Job Application</a></li> <li><a href="home.php?page=Education&section=Internships" class="subMenuLink">Internships</a></li> <li><a href="home.php?page=Employment&section=WorkStudy" class="subMenuLink">Work-Study</a></li> </ul> </div> </div> <!--Mega Drop Down Menu HTML. Retain given CSS classes--> <div id="megamenu5" class="megamenu"> <div class="column"> <ul> <li> <a href="home.php?page=Contact&section=Overview" style="color: #5d829d; font-weight: bold; text-decoration: none; "class="subMenuLink"> Contact Overview</a></li> <li><a href="pdfs/BTIOrgChart.pdf" class="subMenuLink">Organizational Chart</a></li> <li><a href="home.php?page=Contact&section=StaffDirectory" class="subMenuLink">BTI Staff Directory</a></li> <li><a href="home.php?page=Contact&section=Scientists" class="subMenuLink">Scientists</a></li> <li><a href="home.php?page=Contact&section=Research Associate" class="subMenuLink">Research Associates</a></li> <li><a href="home.php?page=Contact&section=Post Doc" class="subMenuLink">Post Docs</a></li> <li><a href="home.php?page=Contact&section=Grad Student" class="subMenuLink">Grad Students</a></li> <li><a href="home.php?page=Contact&section=Research Support" class="subMenuLink">Research Support</a></li> <li><a href="home.php?page=Contact&section=Support" class="subMenuLink">Support</a></li> <li><a href="home.php?page=Contact&section=SeniorLeadership" class="subMenuLink">Senior Leadership</a></li> <li><a href="home.php?page=Contact&section=Management" class="subMenuLink">Management</a></li> <li><a href="home.php?page=Contact&section=Management Scientist" class="subMenuLink">Management/Scientists</a></li> <li><a href="home.php?page=Contact&section=Emeritus Scientist" class="subMenuLink">Emeritus Scientists</a></li> <li><a href="home.php?page=Contact&section=Affiliates" class="subMenuLink">Affiliates</a></li> <li><a href="home.php?page=Map" class="subMenuLink">Directions to Cornell</a></li> </ul> </div> </div> This is the top portion of the header. </head> <body> <div class="container"> <div class="banner"> <div class="bannerMenu"> <div class="siteMapMenu"> <a href="">SiteMap</a> <a href="index.php?page=Intranet&section=Overview">Intranet</a> <a href="http://webportal.bti.cornell.edu/Login.aspx">Web Portal</a> <a href="index.php?page=Contact&section=Overview">People</a> </div> <div class="bannerSearch"><input type='text' id='q' size='18' class="text"></div> <div class="cornellAffiliation"><span style="color:#646a5c;"> The Boyce Thompson Institute is an independent affiliate of</span> <a href="http://www.cornell.edu" style="color: #646a5c;">Cornell University</a></div> </div> </div> <div class="header" style="margin-left: 6px; padding-top: 0px;"> <?php include "includes/mainMenu5.php"; ?> </div> <div class="mainContentBottom"> <div class="mainContent" id='mainContent'>
  15. Hello guys. I currently re-designed a page utilizing a control page. I am using an XHTML strict declaration at the top of my document header file (see below). <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> But when I try to validate I get around 256 errors. And for some reason weird "PHP sessions strings are added to my url's" I have no idea what this is. Below is an example of some of these errors. Can someone help me? # Warning Line 61, Column 74: cannot generate system identifier for general entity "PHPSESSID" …hp?page=Intranet&section=Overview&[b][color=red]PHPSESSID=17b9d814888eb176e68af35bc8f817[/color][/b]… ✉ An entity reference was found in the document, but there is no reference by that name defined. Often this is caused by misspelling the reference name, unencoded ampersands, or by leaving off the trailing semicolon (. The most common cause of this error is unencoded ampersands in URLs as described by the WDG in "Ampersands in URLs". Entity references start with an ampersand (&) and end with a semicolon (. If you want to use a literal ampersand in your document you must encode it as "&" (even inside URLs!). Be careful to end entity references with a semicolon or your entity reference may get interpreted in connection with the following text. Also keep in mind that named entity references are case-sensitive; &Aelig; and æ are different characters. If this error appears in some markup generated by PHP's session handling code, this article has explanations and solutions to your problem. Note that in most documents, errors related to entity references will trigger up to 5 separate messages from the Validator. Usually these will all disappear when the original problem is fixed. # Error Line 61, Column 74: general entity "PHPSESSID" not defined and no default entity …hp?page=Intranet&section=Overview&[b]PHPSESSID=17b9d814888eb176e68af35bc8f817[/b]… ✉ This is usually a cascading error caused by a an undefined entity reference or use of an unencoded ampersand (&) in an URL or body text. See the previous message for further details.
  16. How can I get commas in a text field to not be treated as a delimeter upon exporting?
  17. Hello everyone, I have an application that exports from MySQL to CSV. When I open the CSV file in Excel some of my "text fields" from the MySQL database have a lot of text but some of that text is flowing into other columns. Can it be that upon export the commas within the text fields are being treated as deli meters? here is the function that queries the database. <?php function getSelectedApplicantsCSV($year){ $where_clause = "WHERE reu_year";// = $year AND select_order > 0 "; $applicants = getApplicantsByWhereClause($where_clause); $ret = "id, creation_date, reu_year, last_name, first_name, school_name, school_size, email_address, email_address_alt, phone, enrollmentStatus, high_school_student_year, undergraduate_student_year, highSchoolGPA, major, minor, collegeGPA, graduation_date, reuParticipation, mailingAddress, city, state, zipCode, home_phone, emergency_contact_name, emergency_contact_phone, emergency_contact_relation, birthDate, firstGeneration, gender, ethnicity, programSource, interest1, interest2, interest3, laboratoryExperience, researchExperience, personalStatement, resume\n"; while($row = mysql_fetch_array($applicants)){ //$interests = getInterestsString($row); $ret .= $row['id'] . ", " . $row['creation_date'] . ", " . $row['reu_year'] . ", " . $row['last_name'] . ", " . $row['first_name'] . ", " . $row['school_name'] . ", " . $row['school_size'] . ", " . $row['email_address'] . ", " . $row['email_address_alt'] . ", " . $row['phone'] . ", " . $row['enrollmentStatus'] . ", " . $row['high_school_student_year'] . ", " . $row['undergraduate_student_year'] . ", " . $row['highSchoolGPA'] . ", " . $row['major'] . ", " . $row['minor'] . ", " . $row['collegeGPA'] . ", " . $row['graduation_date'] . ", " . $row['reuParticipation'] . ", " . $row['mailingAddress'] . ", " . $row['city'] . ", " . $row['state'] . ", " . $row['zipCode'] . ", " . $row['home_phone'] . ", " . $row['emergency_contact_name'] . ", " . $row['emergency_contact_phone'] . ", " . $row['emergency_contact_relation'] . ", " . $row['birthDate'] . ", " . $row['firstGeneration'] . ", " . $row['gender'] . ", " . $row['ethnicity'] . ", " . $row['programSource'] . ", " . $row['interest1'] . ", " . $row['interest2'] . ", " . $row['interest3'] . ", " . $row['laboratoryExperience'] . ", " . $row['researchExperience'] . ", " . $row['personalStatement'] . ", " . //preg_replace("/\<br\>/", "", $interests) . ", " . $row['resume'] . "\n"; } return $ret; } ?> and here is my export controller. <?php include_once "../db_config.php"; include_once "functions.php"; $pi_id = $_GET['pi_id']; $pi_id = (null == $pi_id ? -1 : $pi_id); $year = $_GET['year']; $year = (null == $year ? -1 : $year); $applicant_id = $_GET['applicant_id']; $applicant_id = (null == $applicant_id ? -1 : $applicant_id); if($_GET['what'] === "view_selected_csv"){ $csvContent = getSelectedApplicantsCSV($year); @ob_end_clean(); //turn off output buffering to decrease cpu usage // required for IE, otherwise Content-Disposition may be ignored if(ini_get('zlib.output_compression')) ini_set('zlib.output_compression', 'Off'); header("Content-Type: text/csv"); header("Content-Disposition: attachment; filename=\"selected_applicants_$year.csv\""); header("Content-Transfer-Encoding: binary"); header("Accept-Ranges: bytes"); /// The three lines below basically make the download non-cacheable header("Cache-control: private"); header("Pragma: private"); header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); header("Content-Length: " . strlen($csvContent)); echo($csvContent); flush(); return; } ?> does anyone know what I may be missing?
  18. Thank you guys. That pretty much solved my issue. I took Maq's suggestion like so: mysql_real_escape_string($_POST['laboratoryExperience']), mysql_real_escape_string($_POST['researchExperience']), mysql_real_escape_string($_POST['personalStatement']), mysql_real_escape_string($_POST['resume']) So can this function pretty much escape any characters?
  19. When I try to submit text that uses single quote ' and double quote " or a combination of both I receive this error You have an error in your SQL syntax near ''"'' WHERE id = 171' at line 35. Does anyone know what this means and if there is any way to avoid this. Thanks
  20. Does anyone know what where I can find information on the following. I have seen several website that use a single page that then has extensions that follow the actual page. Like "page.php?id=2" or "page.php?page=home" almost like information gets re-routed through a control page that then takes care of the look of that page depending on the page itself. Where can I learn more about this or is there a tutorial here that I can explore? Many Thanks.
  21. I pretty much just want to click on this link <?php echo "<a href='SummerInternStatsCSVTEST.php'>Download Table</a>"; ?> Have it just show the download box this is the function <?php function exportMysqlToCsv($table,$filename = 'export.csv') { $csv_terminated = "\n"; $csv_separator = ","; $csv_enclosed = '"'; $csv_escaped = "\\"; $sql_query = "select * from $table"; // Gets the data from the database $result = mysql_query($sql_query); $fields_cnt = mysql_num_fields($result); $schema_insert = ''; for ($i = 0; $i < $fields_cnt; $i++) { $l = $csv_enclosed . str_replace($csv_enclosed, $csv_escaped . $csv_enclosed, stripslashes(mysql_field_name($result, $i))) . $csv_enclosed; $schema_insert .= $l; $schema_insert .= $csv_separator; } // end for $out = trim(substr($schema_insert, 0, -1)); $out .= $csv_terminated; // Format the data while ($row = mysql_fetch_array($result)) { $schema_insert = ''; for ($j = 0; $j < $fields_cnt; $j++) { if ($row[$j] == '0' || $row[$j] != '') { if ($csv_enclosed == '') { $schema_insert .= $row[$j]; } else { $schema_insert .= $csv_enclosed . str_replace($csv_enclosed, $csv_escaped . $csv_enclosed, $row[$j]) . $csv_enclosed; } } else { $schema_insert .= ''; } if ($j < $fields_cnt - 1) { $schema_insert .= $csv_separator; } } // end for $out .= $schema_insert; $out .= $csv_terminated; } // end while header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Content-Length: " . strlen($out)); // Output to browser with appropriate mime type, you choose header("Content-type: text/x-csv"); //header("Content-type: text/csv"); //header("Content-type: application/csv"); header("Content-Disposition: attachment; filename=$filename"); echo $out; exit; } ?> and the actual file <?php $host = 'localhost'; // MYSQL database host adress $db = 'test'; // MYSQL database name $user = ''; // Mysql Datbase user $pass = ''; // Mysql Datbase password // Connect to the database $link = mysql_connect($host, $user, $pass); mysql_select_db($db); require 'exportcsv.inc.php'; $table="applicants"; // this is the tablename that you want to export to csv from mysql. exportMysqlToCsv($table); ?> but I keep getting this: Warning: Cannot modify header information - headers already sent by (output started at /usr/local/apache/vhosts/boycethompson.com/Summer/internship/exportcsv.inc.php:65) in /usr/local/apache/vhosts/boycethompson.com/Summer/internship/exportcsv.inc.php on line 50 Warning: Cannot modify header information - headers already sent by (output started at /usr/local/apache/vhosts/boycethompson.com/Summer/internship/exportcsv.inc.php:65) in /usr/local/apache/vhosts/boycethompson.com/Summer/internship/exportcsv.inc.php on line 51 Warning: Cannot modify header information - headers already sent by (output started at /usr/local/apache/vhosts/boycethompson.com/Summer/internship/exportcsv.inc.php:65) in /usr/local/apache/vhosts/boycethompson.com/Summer/internship/exportcsv.inc.php on line 53 Warning: Cannot modify header information - headers already sent by (output started at /usr/local/apache/vhosts/boycethompson.com/Summer/internship/exportcsv.inc.php:65) in /usr/local/apache/vhosts/boycethompson.com/Summer/internship/exportcsv.inc.php on line 56
  22. Do any of you know how to make a download link that will download MySQL data as CSV My code is below <?php session_start(); include("../db_config.php"); include("functions.php"); if("getcsv" === $_GET['step']){ $applicants = getAllApplicantInfo(); echo "LAST NAME, FIRST NAME, ASSIGNED PI, PARTICIPATION YEAR, STUDENT RANK\n"; while($row = mysql_fetch_array($applicants)){ echo mysql_real_escape_string( $row['last_name'] ) . ", " . mysql_real_escape_string($row['first_name'] ) . ", " . mysql_real_escape_string($row['pi_first_name'] ) . " " . mysql_real_escape_string($row['pi_last_name'] ) . ", " . "n/a". ", " . mysql_real_escape_string($row['total_points'] ) . "\n"; } return; } ?> any help is greatly appreciated
  23. I have never seen this error before. Parse error: syntax error, unexpected T_ECHO, expecting ',' or ';' in SummerDB/internship/admin_pi.php on line 69 This is my line 69 <?php echo "<input type='hidden' name='pi_eval_applicant_id_" . $count . "' value='" . $row['id'] . "'>\n"; ?> Can someone shed some light into what I may be doing wrong?
  24. ok guys I have a query that pretty much retrieves staff contact data from the database and echo's it out in a table with 1 row and 4 columns. What I'm trying to do is split the returned data into two tables right next to each other both with 1 row and 4 columns. Any help is greatly appreciated. Code: <?php //WHERE category='Affiliate' include 'db_config.php'; $sql = "SELECT * FROM staff_contact_table WHERE active = 1 ORDER BY last_name"; $result = mysql_query($sql); ?> <?php while ($row = mysql_fetch_assoc($result)) { $name = $row['first_name']; $last_name = $row['last_name']; $title = $row['title']; $office = $row['office']; $lab = $row['lab']; $officeTel = $row['office_phone']; $labTel = $row['lab_phone']; $url = preg_replace('@(https?://([-\w\.]+)+(:\d+)?(/([\w/_\.]*(\?\S+)?)?)?)@', '<a href="$1">$1</a>', $row['url']); $email = eregi_replace('([_\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\.)+[a-z]{2,3})','<a href="mailto:\\1">\\1</a>', $row['email']); $title = $row['title']; echo "<table> <tr> <td><b>$last_name, $name</b></td> <td>Office/Lab $office, $lab</td> <td>Office/Lab Tel # $officeTel, $labTel</td> <td>Email: <a href='mailto:$email@cornell.edu'>$email@cornell.edu</a></td> </tr> </table>"; } ?>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.