PHP - 1 Error/issue + 1 Question!
Hi guys, first post here from a relative newbie I'm working on my final project for php and I'm running into a bit of a road block. The error is I'm trying to validate which radio button is checked to run a corresponding function to either add a car, drop a car, or display a car. Everything seems to work fine but my if statement won't pick up the change and therefore my function won't run.
This is the output that I receive from the code. [taken from the bottom of the php when I select Add Car(s) on the form] input = 11112111421 add_status=add_status unchecked=unchecked Here's the script and htm form. Code: [Select] <html> <head> <title>Final Project</title> </head> <body> <form action="final.php" method="post"> <input type="radio" name="query" value="add_status" /> Add Car(s) <br /> <input type="radio" name="query" value="delete_status" /> Delete Car(s) <br /> <input type="radio" name="query" value="display_status" /> Display Car(s) <br /> <input type="text" name="Input_Car_ID" /> Car ID <br /> <input type="text" name="Input_Car_Make" /> Car Make <br /> <input type="text" name="Input_Car_Model" /> Car Model <br /> <input type="text" name="Input_Car_Vin" /> Car Vin <br /> <input type="text" name="Input_Car_Color" /> Car Color <br /> <input type="text" name="Input_Car_Mileage" /> Car Mileage <br /> <input type="Submit" value="Query" /> </form> </body> </html> <!-- Radio button selects which functions to run. Leave blank to view all --> <?php /* final.php Name: Peter Cort Date: 4/25/2012 Script: Final Project */ $add_status = "unchecked"; $drop_status = "unchecked"; $display_status = "unchecked"; extract($_POST, EXTR_SKIP); if (isset ($Submit)){ if ($query == "add_status") { $add_status = "checked"; } else if ($query == "drop_status") { $drop_status = "checked"; } else if ($query == "display_status") { $display_status = "checked"; } } function runsql(){ /*mysql_connect("sftweb01", "cort", "peter");*/ mysql_connect("localhost", "peter", "cort"); mysql_select_db("cort"); } runsql(); if ( empty($Input_Car_ID)) { $Input_Car_ID = ""; } if ( empty($Input_Car_Make)) { $Input_Car_Make = ""; } if ( empty($Input_Car_Model)) { $Input_Car_Model = ""; } if ( empty($Input_Car_Vin)) { $Input_Car_Vin = ""; } if ( empty($Input_Car_Color)) { $Input_Car_Color = ""; } if ( empty($Input_Car_Mileage)) { $Input_Car_Mileage = ""; } class car{ private $Car_ID; private $Car_Make; private $Car_Model; private $Car_Vin; private $Car_Color; private $Car_Mileage; public $Input_Car_ID; public $Input_Car_Make; public $Input_Car_Model; public $Input_Car_Vin; public $Input_Car_Color; public $Input_Car_Mileage; /* function for setting no input values to null (will be able to delete on multiple paramaters) */ /* function needs to get values from the .htm form */ function __construct($Input_Car_ID, $Input_Car_Make, $Input_Car_Model, $Input_Car_Vin, $Input_Car_Color, $Input_Car_Mileage) { $this->Car_ID = $Input_Car_ID; $this->Car_Make = $Input_Car_Make; $this->Car_Model = $Input_Car_Model; $this->Car_Vin = $Input_Car_Vin; $this->Car_Color = $Input_Car_Color; $this->Car_Mileage = $Input_Car_Mileage; } function add_vehicle() { if (($Car_ID == "") && ($Car_Make == "") && ($Car_Model == "") && ($Car_Vin == "") && ($Car_Color == "") && ($Car_Mileage == "")) { print "Please provide information about the car you wish to add"; } else mysql_query("INSERT INTO Car_T (Car_ID, Car_Make, Car_Model, Car_Vin, Car_Color, Car_Mileage) VALUES ('$this->Car_ID', '$this->Car_Make','$this->Car_Model', '$this->Car_Vin', '$this->Car_Color', '$this->Car_Mileage')"); } function drop_vehicle() { if (($Car_ID == "") && ($Car_Make == "") && ($Car_Model == "") && ($Car_Vin == "") && ($Car_Color == "") && ($Car_Mileage == "")) { print "Please provide information about the car you wish to delete"; } else mysql_query("DELETE FROM Car_T WHERE Car_ID = '$this->Car_ID' AND Car_Make='$this->Car_Make' AND Car_Model='$this->Car_Model' AND Car_Vin='$this->Car_Vin' AND Car_Color='$this->Car_Color' AND Car_Mileage='$this->Car_Mileage'"); } function display_vehicle() { if (($Car_ID == "") && ($Car_Make == "") && ($Car_Model == "") && ($Car_Vin == "") && ($Car_Color == "") && ($Car_Mileage == "")) { $display_query = mysql_query("SELECT * FROM Car_T"); } else $display_query = mysql_query("SELECT * FROM Car_T WHERE (Car_ID = '$this->Car_ID' OR Car_Make = '$this->Car_Make' OR Car_Model = '$this->Car_Model' OR Car_Vin = '$this->Car_Vin' OR Car_Color = '$this->Car_Color' OR Car_Mileage = '$this->Car_Mileage')"); while($row = mysql_fetch_row($display_query)){ echo $row['$this->Car_ID']; print "<br />"; } } function display_stuff() { echo $this->Car_ID; echo $this->Car_Make; echo $this->Car_Model; echo $this->Car_Vin; echo $this->Car_Color; echo $this->Car_Mileage; } } $new_entry = new car($Input_Car_ID, $Input_Car_Make, $Input_Car_Model, $Input_Car_Vin, $Input_Car_Color, $Input_Car_Mileage); if ($add_status == 'checked'){ $new_entry->add_vehicle(); } if ($drop_status == 'checked'){ $new_entry->drop_vehicle(); } if ($display_status == 'checked'){ $new_entry->display_vehicle(); } print "<br />"; print "input = "; $new_entry->display_stuff(); print "<br />"; print "$query"; print "="; print $query; print "<br />"; print "$add_status"; print "="; print $add_status; /* $Car_ID, $Car_Make, $Car_Model, $Car_Vin, $Car_Color, $Car_Mileage print $Input_Car_ID; print $Input_Car_Make; print $Input_Car_Model; print $Input_Car_Vin; print $Input_Car_Color; print $Input_Car_Mileage; print "<br />"; */ ?> My second part of this is wondering how to construct my display query to run right. I'd like to be able to run it on any possible input from the text box. I basically want to do something like (WHERE LIKE '%') where there isn't an input from the htm form. My thought was to build the query on a series of concatenations through a function, but that seems like a lot of work. I just feel like it's important to give that functionality to the program. Thanks for looking, and hopefully I don't confuse you readers that much :3 Also I know that the mysql_query(); is going out of style but just go with it for the sake of my sanity Similar TutorialsMy table has 250 rows, but COUNT only seems to see 162 of them. In phpMyAdmin, for instance, there is a notice in the browse tab: "Showing rows 0-161 (162 total, Query took 0.0030 sec)". On one of my php pages, I get the same 162 result from this attempt to count the number of entries to my auto-incrementing "id" column :
$result = mysql_query('SELECT COUNT(id) AS id_count FROM MyTable)';Can anyone suggest the kinds of things I should check/adjust to understand why about 90 rows are not being counted? Many thanks in advance for any help anyone can offer. please help me in php i want that when a user clicks on add click a new box will be appeared for question consider user is doing work with questions and options he first gives a question after it he clicks on ADD button so a input box will appear den he clicks again to ADD button den aggain new box appears at last he clicks save then they would be inserted into database reply mee.. please Ok here it is, seems like it is an easy problem but my developers are having some issue with this, I hope you guys can help. Basic question and answer problem, where I am developing a website that uses Items and questions like " How many of this Item do you need?" the answer seems to simple. Lets say the answer Is "1". The display is given to the Item list and we move on. Here is the Problem: When selecting Muiltiple Items in the List and they all have the same question associated to each Item: "How Many Items do you need?" the the answer is shared between the Items, Again, sounds simple so far, However, when the USER selects Multiple Items on a list say 30 Items then the Question should only be dispalyed one time, not 30 times, then the answer is shared 30 times. Thats what I have now being displayed on my website, 30 of the same questions over and over again. The USER will get frustrated and leave the site never to return. Question: How can I get the Question to be displayed only once, but shared between several items on a list? This is a very serious problem fo my website because I will have not have just one Item on a list but 300 to 400 items, and if I get the answer to the problem I have just wasted 1 year of my life developing something undevelopable (is that a word?). Any Help you can give me would greatly be appricated. Thank you in advance. Hi: I have another small issue like the one I just posted about. I am trying to get the full state name based upon the state abbreviation. Like this: Code: [Select] <?php $query=mysql_query("SELECT full_state FROM zip_codes WHERE abbr_state = abbr_state") or die("Could not get data from db: ".mysql_error()); $full_state=$result['full_state']; ?> ... State Name: <input type="text" name="full_state" value="<?php echo $full_state; ?>" /><br /> [CODE] No errors, but also no "full_state" appears. (It is pulling in the correct "abbr_state") What am I missing here? The below is flagging errors #3 and #9. Error #3 is being thrown even though the emails match. Code: [Select] <?php session_start(); $_SESSION['submitted']="yes"; $error=$_GET['error']; $date_rma="5/10/2011"; $content=' <div class="content_text"> <div class="content_header">Request RMA Number</div> <p>Enter the information you used on PayPal, that you completed your order with. The information must match, or a RMA Number will not be issued.</p> <form action="./rma_process.php" method="post"> <p><label>Name:</label> <input type="text" name="name" size="30" value="'.(isset($_SESSION['name']) ? $_SESSION['name'] : '').'" />'; if($error[0]==1){ $content.=' <span class="red bold">This field is required.</span>'; } $content.='</p> <p><label>E-Mail Address:</label> <input type="email" name="email" size="35" value="'.(isset($_SESSION['email']) ? $_SESSION['email'] : '').'" />'; if($error[1]==1){ $content.=' <span class="red bold">This field is required.</span>'; } $content.='</p> <p><label>Confirm E-Mail Address:</label> <input type="email" name="confirm_email" size="35" value="'.(isset($_SESSION['confirm_email']) ? $_SESSION['confirm_email'] : '').'" />'; if($error[2]==1){ $content.=' <span class="red bold">This field is required.</span>'; } if($error[3]==1){ $content.=' <span class="red bold">E-Mail addresses do not match.</span>'; } $content.='</p> <p><label>Phone Number:</label> <input type="text" name="phone" size="15" value="'.(isset($_SESSION['phone']) ? $_SESSION['phone'] : '').'" /> Ext. <input type="text" name="ext" size="4" value="'.(isset($_SESSION['ext']) ? $_SESSION['ext'] : '').'" />'; if($error[4]==1){ $content.=' <span class="red bold">A properly formatted phone number is required.</span>'; } $content.='</p> <p><label>Date of Purchase (MM/DD/YYYY):</label><input type="text" name="month" size="2" maxlength="2" value="'.(isset($_SESSION['month']) ? $_SESSION['month'] : '').'" /> <input type="text" name="day" size="2" maxlength="2" value="'.(isset($_SESSION['day']) ? $_SESSION['day'] : '').'" /> <input type="text" name="year" size="5" maxlength="4" value="'.(isset($_SESSION['year']) ? $_SESSION['year'] : '').'" />'; if($error[5]==1 || $error[6]==1 || $error[7]==1){ $content.=' <span class="red bold">A properly formatted date is required.</span>'; } $content.='</p><p><label>List the Products you wish to return. Sperate with a comma. <br />Use either the whole product name, or the GHP# Product Code:</label>'; if($error[8]==1){ $content.=' <span class="red bold">This field is required.</span>'; } $content.='<textarea name="products_returning" rows="10" cols="60"> '.(isset($_SESSION['products_returning']) ? $_SESSION['products_returning'] : '').''; $content.=' </textarea> <input type="hidden" name="submitted" value="yes" /> </p> <p><input type="submit" value="Submit" name="Submit" /></p> </form> </div> '; ?> Code: [Select] <?php session_start(); $name = $_POST['name']; $_SESSION['name']=$name; if($name==""){ $error0=1; } else{ $error0=0; } $email = $_POST['email']; $_SESSION['email']=$email; if($email==""){ $error1=1; } else{ $error1=0; } $confirm_email = $_POST['confirm_email']; $_SESSION['confirm_email']=$confirm_email; if($confirm_email==""){ $error2=1; } else{ $error2=0; } if($email!=$confirm_email){ $error3=1; } else{ $error3=0; } $phone = $_POST['phone']; $_SESSION['phone']=$phone; if($phone==""){ $error4=1; } else{ $error4=0; } $ext = $_POST['ext']; $_SESSION['ext']=$ext; $phone = $phone.' Ext.'.$ext; $month = $_POST['month']; $_SESSION['month']=$month; if($month=="" || !is_numeric($month)){ $error5=1; } else{ $error5=0; } $day = $_POST['day']; $_SESSION['day']=$day; if($day=="" || !is_numeric($day)){ $error6=1; } else{ $error6=0; } $year = $_POST['year']; $_SESSION['year']=$year; if($year=="" || !is_numeric($year)){ $error7=1; } else{ $error7=0; } $date="".$month."/".$day."/".$year.""; $products_returning = $_POST['products_returning']; $_SESSION['products_returning']=$products_returning; if($products_returning==""){ $error8=1; } else{ $error8=0; } if($_SESSION['submitted']=="yes"){ $error9=0; } else{ $error9=1; } $error="".$error0."".$error1."".$error2."".$error3."".$error4."".$error5."".$error6."".$error7."".$error8."".$error9.""; if($error!=="0000000000"){ header("Location: ./index.php?returns=rma&error=".$error0."".$error1."".$error2."".$error3."".$error4."".$error5."".$error6."".$error7."".$error8."".$error9.""); } else{ header("Location: ./index.php?returns=submitted"); } ?> Hi folks, a few days back, we enabled SSL on our office server and the intranet migrated to https. Everything is ok on the intranet. On the public internet, we noticed today that the page on our website, which connects to our office server to fetch and display data was throwing an error, which I presumed was a Security Certificate issue... An area that's like the Dark Side of the Moon for me.. the webpage - https://liveconnections.in/hotjobs.php This is the error from the logs PHP Warning: file_get_contents(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed PHP Warning: file_get_contents(): Failed to enable crypto PHP Warning: file_get_contents(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed
Anycase, the internet was willing to help and so I updated the code to a curl function. The Data is not displaying still... Here's the code... where am i going wrong ? <?php //error_reporting(E_ERROR | E_PARSE | E_ALL); $page="jobs-listing"; ?> <header class="section background-livec text-center"> <h3 class="text-white margin-bottom-0 text-size-40 text-thin text-line-height-1">Current & Hot Jobs</h3> </header> <?php $industry = $_GET['industry']; $location = $_GET['location']; $expMin = $_GET['expMin']; $expMax = $_GET['expMax']; $sortBy = $_GET['sortBy']; $cpg = $_GET['page']; if(empty($cpg) || $cpg==1) $npl = 1; else { //$npl = (($cpg+1)*10) - 9; $npl = $_GET['startingRowNo']; } $industry = str_replace(' ', '%20', $industry); $location = str_replace(' ', '%20', $location); $url = "https://xx.xxx.xxx.xxx/WebService/rest/"; function file_get_contents_curl($url) { $ch = curl_init(); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //Set curl to return the data instead of printing it to the browser. curl_setopt($ch, CURLOPT_URL, $url); $data = curl_exec($ch); curl_close($ch); return $data; } if(!empty($sortBy)) { $json = file_get_contents_curl($url.'getHeadersBySearch?industry='.$industry.'&location='.$location.'&expMin='.$expMin.'&expMax='.$expMax.'&sortBy='.$sortBy.'&startingRowNo='.$npl.'&noOfRows=1000000'); $data = json_decode($json); } else if(!empty($industry) || !empty($location) || !empty($expMin) || !empty($expMax)) { $json = file_get_contents_curl($url.'getHeadersBySearch?industry='.$industry.'&location='.$location.'&expMin='.$expMin.'&expMax='.$expMax.'&sortBy=&startingRowNo='.$npl.'&noOfRows=1000000'); $data = json_decode($json); } else { //$json = file_get_contents_curl($url.'getOnlineWebPosting'); $json = file_get_contents_curl($url.'getHeadersBySearch?industry='.$industry.'&location='.$location.'&expMin='.$expMin.'&expMax='.$expMax.'&sortBy=&startingRowNo='.$npl.'&noOfRows=1000000'); $data = json_decode($json); //if (!$data) echo "Data Not Found" ; } if($sortBy=='DESC' || $sortBy=='') { $aclass = 'down_arrow'; } else { $aclass = 'up_arrow'; } $json2 = file_get_contents_curl($url.'getSearchData'); $data2 = json_decode($json2); $industry = str_replace('%20', ' ', $industry); $location = str_replace('%20', ' ', $location); if($industry=='F amp A - BPO') { $industry = 'F & A - BPO'; } if($industry=='OIL amp GAS') { $industry = 'OIL & GAS'; } ?> <div class="section background-white"> <div class="background-white"> <p class="text-padding-bot text-letter-spacing1">A cross-section of Jobs currently available. We recommend you to contact our Executives for further info. <br /> More details available when the Job is '<strong>View'</strong>ed. </p> </div> <?php //$data=''; //if($data!=''){ ?> <?php //if ($checkyear>2017) { ?> <div class="subJobs"> <ul> <li> Industry <br /> <select name="industry" id="industry" class="sel"> <option value="">Select Industry Name</option> <?php for($i=0; $i<count($data2[0]); $i++) { ?> <?php if(isset($industry) && $industry==$data2[0][$i]) { ?> <option selected value="<?php echo $data2[0][$i];?>"><?php echo $data2[0][$i];?></option> <?php } else { ?> <option value="<?php echo $data2[0][$i];?>"><?php echo $data2[0][$i];?></option> <?php } } ?> </select> </li> <li>Location<br /> <select name="city" id="city" class="sel"> <option value="">Select City Name</option ><?php $m=0; for($j=0; $j<count($data2[1]); $j++) { ?> <?php $locat = explode(",",$location); ?> <?php if($locat[$m]!="" && $locat[$m]==$data2[1][$j]) { ?> <option selected value="<?php echo $data2[1][$j];?>"><?php echo $data2[1][$j];?></option> <?php ++$m; } else { ?> <option value="<?php echo $data2[1][$j];?>"><?php echo $data2[1][$j];?></option> <?php } } ?> </select> </li> <li>Experience <br /> <select name="minyear" class="sel2" id="minyear"> <option value="">Min</option> <?php for($ii=0; $ii<46; $ii++) { ?> <?php if($expMin!="" && $expMin==$ii) { ?> <option selected value="<?php echo $ii; ?>"><?php echo $ii; ?></option> <?php } else { ?> <option value="<?php echo $ii; ?>"><?php echo $ii; ?></option> <?php } } ?> </select> <select name="maxyear" class="sel2" id="maxyear" onchange="return select_max();"> <option value="">Max</option> <?php for($ii=0; $ii<51; $ii++) { ?> <?php if($expMax!="" && $expMax==$ii) { ?> <option selected value="<?php echo $ii; ?>"><?php echo $ii; ?></option> <?php } else { ?> <option value="<?php echo $ii; ?>"><?php echo $ii; ?></option> <?php } } ?> </select> <!-- select name="" class="sel2" id="sort"> <option value="">Select</option> <option value="ASC">ASC</option> <option value="DESC">DESC</option> </select --> </li> <li class="ser"><button type="button" onclick="search_by_category()" class="btn btn-default" style="margin-top:25px;"><i class="fa fa-search"></i> Search</button></li> </ul> </div> <!-- Selected Jobs Headline Info --> <div class="line"> <p class="text-dark text-center text-size-16"> <?php if($industry) echo 'Showing ' . '<b>' . $industry .'</b>' . ' Jobs' ; ?> <?php if($location) echo ' at ' . '<b>' . $location .'</b>' ; ?> <?php if($expMin) echo ' with Min ' . '<b>' . $expMin .'</b>' ; ?> <?php if($expMax) echo ' to Max '. '<b>' . $expMax.'</b>' ; ?> <?php if($expMin | $expMax) echo ' Years Experience' ;?> </p> </div> <!-- Jobs Table --> <table id="example" class="display" cellspacing="0" width="100%"> <thead> <tr> <th class="jobs_noshow text-center" width="5%">S.No</th> <th class="text-center" width="15%">Posted On</th> <th class="text-center" width="30%">Job Title</th> <th class="jobs_noshow text-center" width="15%">Level</th> <th class="jobs_noshow text-center" width="15%">Location</th> <th class="jobs_noshow text-center" width="15%">Job Code</th> <th class="text-center" width="5%">Action</th> </tr> </thead> <tbody> <?php $ri=1; foreach($data as $kk=>$d) { ?> <?php $date_posted = $d->postedDate; // get the Posted Date $date_posted_year=date("Y",strtotime($date_posted)); // Get the Year from the date and store in a variable if ($date_posted_year>$jobs_restrict_year) { // Show only Jobs posted after this year ?> <tr> <td class="jobs_noshow text-center"><?php echo $ri; ?></td> <td class="text-center"><?php echo $d->postedDate; ?></td> <td><?php echo $d->title; ?></td> <td class="jobs_noshow ctext notreq"><?php echo $d->level; ?></td> <td class="jobs_noshow text-center notreq"><?php echo $d->location; ?></td> <td class="jobs_noshow text-center"><?php echo $d->requirementID; ?></td> <td class="text-center"><a class="button background-livec border-radius text-white" style="color:white" data-fancybox="ajax" href="?contentid=jobs-detail&requirementID=<?php echo $d->requirementID; ?>&requirementSeqNo=<?php echo $d->requirementSeqNo; ?>" data-type="ajax">View</a></td> </tr> <?php } ?> <?php $ri=$ri+1; } ?> </tbody> </table> <script type="text/javascript"> $(document).ready(function () { var table = $('#example').DataTable( { "pageLength": 25, "sPaginationType":"full_numbers", "oLanguage": { "sInfo": 'Showing _START_ to _END_ of _TOTAL_ Jobs.', "sInfoEmpty": '', "sEmptyTable": "No Jobs found currently", } }); $('#example').removeClass( 'display' ).addClass('table table-striped table-bordered'); }); </script> <style> .dataTables_filter { display: none; } </style> <!-- End of Table --> </div> <?php // } else { ?> <div style="margin: 20px 0 40px 0px;height:200px;text-align:center;"> <h1 style="font-size:16px;">Server is unavailable at the moment. Please try after some time.</h1> </div> <?php //}?> </div> <!--jobs end--> <script type="text/javascript"> function search_by_category() { industry = $('#industry option:selected').val(); //city1 = $('#city option:selected').val(); minyear = $('#minyear option:selected').val(); maxyear = $('#maxyear option:selected').val(); //sortBy = $('#sort option:selected').val(); var city = $('select#city').val(); var cur_pg = "<?php echo $cpg; ?>"; var tot = "<?php echo $total; ?>"; var tot_pgs = Math.ceil(tot/25); //if(cur_pg=="") cur_pg = 1; var last_pg = tot_pgs - cur_pg; if(last_pg==0) records = tot - ((tot_pgs -1) * 25); else records = 25; var strt_val = ((cur_pg-1) * 25) + 1; if(industry=='F & A - BPO') industry ='F amp A - BPO'; if(industry=='OIL & GAS') industry ='OIL amp GAS'; city1 = document.getElementById("city").value; if(city1=="" || city1=="null") { city=""; } if(industry!="" || city!="" || minyear!="" || maxyear!="") { location.href="hotjobs.php?contentid=hotjobs&industry="+industry+"&location="+city+"&expMin="+minyear+"&expMax="+maxyear+"&sortBy=&startingRowNo=1"+"&noOfRows="+records+"&page="+cur_pg; } else { //alert("Please select any one of the fields"); location.href="hotjobs.php?contentid=hotjobs&industry="+industry+"&location="+city+"&expMin="+minyear+"&expMax="+maxyear+"&sortBy=&startingRowNo=1"+"&noOfRows="+records+"&page="+cur_pg; } } function sort_by_location() { var order = '<?php echo $sortBy; ?>'; industry = $('#industry option:selected').val(); city = $('#city option:selected').val(); minyear = $('#minyear option:selected').val(); maxyear = $('#maxyear option:selected').val(); city1 = document.getElementById("city").value; if(industry=='F & A - BPO') industry ='F amp A - BPO'; if(industry=='OIL & GAS') industry ='OIL amp GAS'; if(city1=="") { city=""; } else { city = $('select#city').val(); } if(order=="" || order=="DESC") { location.href="hotjobs.php?contentid=hotjobs&industry="+industry+"&location="+city+"&expMin="+minyear+"&expMax="+maxyear+"&sortBy=ASC"+"&startingRowNo=1&noOfRows=10"; } else { location.href="hotjobs.php?contentid=hotjobs&industry="+industry+"&location="+city+"&expMin="+minyear+"&expMax="+maxyear+"&sortBy=DESC"+"&startingRowNo=1&noOfRows=10"; } } function select_max() { minyear = document.getElementById("minyear").value; maxyear = document.getElementById("maxyear").value; if(parseInt(maxyear)>=parseInt(minyear)) { return true; } else { if(maxyear!="") { alert("Maximum year must be equal or greater than minimum year"); $('#maxyear').val(""); return false; } } } </script> Also, if i change the $url in my code to https:// , no data is displayed... I raised a Support request to the Hosting provider, but they seem to have vanished into the ozone.... Any help would be highly appreciated. Cheers - Murali
Hello, I'm having an issue that I just can't seem to figure out. I have two include files - one that contains a function to return credentials for accessing the database and the other that generates/sends email. The issue that I'm having is that if I can change all the include_once to include, I get a fatal error that the function can't be redeclared. When I leave them as include_once, the first time the database credentials are needed, it works but subsequent calls to the function later in the code fail. I feel like I'm missing something very simple but just can't figure it out for the life of me. Thank you SO much for any help - I tried to illustrate my files/code below. Thank you! Jason Filename: access.php Purpose: Functions to provide database credentials to other functions/code function getDatabaseDetails() { //CODE IS HERE } Filename: email.php Purpose: Functions to retrieve data from DB and send email function sendEmail() { include_once '/includes/access.php' //CODE IS HERE } Filename: page.php Purpose: Actual content include_once '/includes/access.php' include_once '/includes/email.php' //CODE IS HERE Hey guys.. I've been setting up a database for a contact page and I have everything working for it except the following error on my update contact page.. can anyone help me figure it out?? The error lines are the ones where I have my mysql_result's. Errors: No Records Found Warning: mysql_result() [function.mysql-result]: Unable to jump to row 0 on MySQL result index 3 in /home/jonnyp22/public_html/a5/update_contact.php on line 103 Warning: mysql_result() [function.mysql-result]: Unable to jump to row 0 on MySQL result index 3 in /home/jonnyp22/public_html/a5/update_contact.php on line 104 Warning: mysql_result() [function.mysql-result]: Unable to jump to row 0 on MySQL result index 3 in /home/jonnyp22/public_html/a5/update_contact.php on line 105 Warning: mysql_result() [function.mysql-result]: Unable to jump to row 0 on MySQL result index 3 in /home/jonnyp22/public_html/a5/update_contact.php on line 106 Warning: mysql_result() [function.mysql-result]: Unable to jump to row 0 on MySQL result index 3 in /home/jonnyp22/public_html/a5/update_contact.php on line 107 Warning: mysql_result() [function.mysql-result]: Unable to jump to row 0 on MySQL result index 3 in /home/jonnyp22/public_html/a5/update_contact.php on line 108 Warning: mysql_result() [function.mysql-result]: Unable to jump to row 0 on MySQL result index 3 in /home/jonnyp22/public_html/a5/update_contact.php on line 109 Warning: mysql_result() [function.mysql-result]: Unable to jump to row 0 on MySQL result index 3 in /home/jonnyp22/public_html/a5/update_contact.php on line 110 Warning: mysql_result() [function.mysql-result]: Unable to jump to row 0 on MySQL result index 3 in /home/jonnyp22/public_html/a5/update_contact.php on line 111 Code: [Select] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta content="text/html; charset=utf-8" http-equiv="Content-Type" /> <title>Update Contact</title> <script type="text/javascript"> function Validateform(){ var email=document.form1.email; var firstname=document.form1.firstname; var lastname=document.form1.lastname; var state=document.form1.state; var reEmail = /^(?:\w+\.?)*\w+@(?:\w+\.)*\w+$/; if ((email.value==null)||(email.value=="")){ alert("Please enter email address"); email.focus(); return false; } if (reEmail.test(email.value)==false){ alert ("Please enter valid email address"); email.focus(); return false; } if ((firstname.value=="")||(firstname.value==null)) { alert("Please enter first name"); firstname.focus(); return false; } if ((lastname.value=="")||(lastname.value==null)) { alert("Please enter last name"); lastname.focus(); return false; } if (state.selectedIndex==0) { alert("Select state"); state.focus(); return false; } return true; } </script> <style type="text/css"> .style1 { text-align: center; color: #F8B57E; font-size: x-large; } .style2 { text-align: center; } .style3 { text-align: right; color: #F8B57E; } .style4 { text-align: left; } .style6 { text-align: center; color: #F8B57E; font-size: medium; } .style7 { color: #FFFFFF; } </style> </head> <body style="color: #FFFFFF; background-color: #102541"> <div class="style2"> <p class="style1"><strong>Update Contact</strong></p> <p class="style6">* Indicates a Required Field</p> <?php include("dl.php"); // If the form has not been submitted then show it if(!$_POST['Submit']) { $email=$_GET['email']; $query="SELECT * FROM person WHERE Email = '$email'"; $result=mysql_query($query) or die('Error: ' . mysql_error()); $num=mysql_numrows($result); mysql_close(); if ($num == 0) { echo "<b><center>No Records Found</center></b>"; } $lastname=mysql_result($result,0,"Last_Name"); $email=mysql_result($result,0,"Email"); $firstname=mysql_result($result,0,"First_Name"); $address1=mysql_result($result,0,"address1"); $address2=mysql_result($result,0,"address2"); $city=mysql_result($result,0,"city"); $state=mysql_result($result,0,"state"); $zip=mysql_result($result,0,"zip"); $phone=mysql_result($result,0,"phone"); ?> <form action="<?=$_SERVER['PHP_SELF']?>" method="post"> <table style="width: 100%"> <tr> <td style="width: 219px; height: 26px" valign="top" class="style3">E-mail Address:</td> <td style="height: 26px" class="style4"> <input name="email" style="width: 363px" type="text" value="<? echo $email; ?>" readonly="readonly" /> </td> </tr> <tr><td class="style3">First Name:</td><td class="style4"><input type="text" name="firstname" id="firstname" size="30" width="250px" value="<? echo $firstname; ?>"/></td></tr> <tr> <td class="style3" >Last Name:</td><td class="style4" ><input name="lastname" id="lastname" type="text" size="30" width="250px" value="<? echo $lastname; ?>"/></td> </tr> <tr><td class="style3">Phone:</td><td class="style4"><input type="text" name="phone" id="phone" size="15" width="250px" value="<? echo $phone; ?>"/></td></tr> <tr> <td class="style3">Address Line 1:</td><td class="style4"><input type="text" name="address1" id="address1" size="50" width="250px" value="<? echo $address1; ?>" /></td></tr> <tr> <td class="style3">Address Line 2:</td><td class="style4"><input type="text" name="address2" id="address2" size="50" width="250px" value="<? echo $address2; ?>"/></td></tr> <tr><td class="style3">City:</td><td class="style4"><input type="text" name="city" id="city" size="50" width="250px" value="<? echo $city; ?>"/></td></tr> <tr><td class="style3">State:</td><td class="style4"><select name="state" id="state"> <option <? if ($state=="NJ") echo selected ;?> >NJ</option> <option <? if ($state=="NY") echo selected ;?> >NY</option> </select></td></tr> <tr><td class="style3">Zip:</td><td class="style4"><input type="text" name="zip" id="zip" size="5" value="<? echo $zip; ?>"/></td></tr> </table> <p class="style2"><input name="Submit" type="submit" value="Update" /> <a href="show_contacts.php"><span class="style7">Show Contacts</span></a> <br /> </p> </form> <?php } else { // The form has been submitted so process it $email=$_POST['email']; $lastname=$_POST['lastname']; $firstname=$_POST['firstname']; $phone=$_POST['phone']; $address1=$_POST['address1']; $address2=$_POST['address2']; $city=$_POST['city']; $state=$_POST['state']; $zip=$_POST['zip']; $query="UPDATE person SET Last_Name='$lastname',FIRST_Name='$firstname',Phone='$phone', Address1='$address1', Address2='$address2', city='$city', state='$state',zip='$zip' WHERE Email='$email'"; if (!mysql_query($query,$con)) { die('Error: ' . mysql_error()); } else { echo "<center><b> Contact info $lastname updated successfully </b><a href='show_contacts.php'>show contacts</a></center>"; } mysql_close(); } ?> </div> </body> </html> I think this is a simple question, but I'm just starting out and can't figure out how to do this exactly. I'm making a demo site for a flower shop. The structure is as such (only listing the particular files in question - once this is done, the rest will be easy) index.php -> inc_show_colors.php -> showColors.php The index is to be standard through the site, loading include files into a main content area. Clicking on a link loads inc_by_color.php (index.php -> index.php?page=by_color ) From there, one of the four colors is selected. showColors.php contains switch statements for each color. I want to load showColors.php into the main content window when a color is selected, and I need to have it work for all four colors. I'm not sure how to do this, as you can't pass a variable to an include from what I understand. What's the easiest way to go about this? Keep in mind this is an intro class and "best practices" are not necessary yet, just the simplest solution to get it working. I want each of these colors to link to another include file, which will load in its place in index.php. index.php: Code: [Select] <div id="maincontent"> <?php if (isset($_GET['page'])) { switch ($_GET['page']) { case 'by_color': include('includes/inc_by_color.php'); break; case 'by_type': include('includes/inc_by_type.php'); break; case 'by_occasion': include('includes/inc_by_occasion.php'); break; case 'view_cart': include('includes/inc_view_cart.php'); break; case 'payment_options': include('includes/inc_payment_options.php'); break; case 'home_page': default: include('includes/inc_home.php'); break; } } else include('includes/inc_home.php'); ?> </div> inc_by_color.php: The first link I tried doing in the way I thought would work, but it doesn't. It can't find the include file. The second one works, kind of - but it just loads the page by itself, not into the maincontent div in index.php. Code: [Select] <h1>Flowers Categorized by Color</h1> <div class="picdivcontainer"> <div class="picdiv"><a href="index.php?page=red"><img src="images/image.png" width="90" height="90" alt="Red Flowers" /> <p>Red</a></p></div> <div class="picdiv"><a href="showColors.php?color=white"><img src="images/image.png" width="90" height="90" alt="White Flowers" /></a> <p><a href="showColors.php?color=white">White</a></p></div> </div> and showColors.php: Code: [Select] if (isset($_GET['color'])) { switch ($_GET['color']) { case 'red': $result = mysql_query("SELECT * FROM flowers WHERE color='red'") or die(mysql_error()); while($row = mysql_fetch_array( $result )) { // Set and trim strings and show the resulting flowers from query $flowername = $row['name']; $flowerimage = $row['image']; $image_path = "images/"; $flowername = str_replace('_', ' ', $flowername); $flowername = ucwords($flowername); ?> <div class="picdiv"><p><?php echo $flowername."<br />"; $flowerimage = str_replace(' ', '_', $flowerimage); echo "<img src='images/" . $row['image'] . "' />"; ?></p></div> <?php } break; I realize that showColors.php is probably a really messy way of doing this, but I just need to get it functioning ASAP for now. Hey guys.. I'm new to the forum and have a quick question about some coding i've been doing for my website. A couple index errors are coming up when I run my code, but I believe it all should be working fine. I am going to paste the code, but also upload the files so that you can understand the problem better. ANY help is greatly appreciated. I am currently making a contact form with validation. I know that using ifempty() is probably the best way, but I am unclear as to how to use it. I have two files, an html containing my form, and a php file containing the following code: //Define Variables $FirstName = $_GET['FirstNameTextBox']; $LastName = $_GET['LastNameTextBox']; $PhoneNumber = $_GET['PhoneNumberTextBox']; $EmailAddress = $_GET['EmailAddressTextBox']; $Address = $_GET['AddressTextBox']; $City = $_GET['CityTextBox']; $State = $_GET['StateDropDownBox']; $Zip = $_GET['ZipTextBox']; $error1='*Please enter a First Name<br>'; $error2='*Please enter a Last Name<br>'; $error3='*Please enter a Phone Number<br>'; $error4='*Please choose a state<br>'; $error5='*Please enter a valid email address<br>'; $day2 = mktime(0,0,0,date("m"),date("d")+2,date("Y")); $day3 = mktime(0,0,0,date("m"),date("d")+3,date("Y")); $day7 = mktime(0,0,0,date("m"),date("d")+7,date("Y")); if($FirstName=="") {echo $error1; exit;} if($LastName=="") {echo $error2; exit;} if($PhoneNumber=="") {echo $error3; exit;} if($State=="") {echo $error4; exit;} if($EmailAddress=="") {echo $error5; exit;} if($State == "NY") { echo "$FirstName $LastName - we will get back to you within 2 days, ie before " .date("d M Y", $day2); exit; } if($State == "NJ") { echo "$FirstName $LastName - we will get back to you within 3 days, ie before " .date("d M Y", $day3); exit; } if($State == "Other") { echo "$FirstName $LastName - we will get back to you within 1 week, ie before " .date("d M Y", $day7); exit; } The following errors come up: Notice: Undefined index: FirstNameTextBox in C:\Users\Jonny P\Documents\My Web Sites\JMPMySite\AddContact.php on line 14 Notice: Undefined index: LastNameTextBox in C:\Users\Jonny P\Documents\My Web Sites\JMPMySite\AddContact.php on line 15 Notice: Undefined index: PhoneNumberTextBox in C:\Users\Jonny P\Documents\My Web Sites\JMPMySite\AddContact.php on line 16 Notice: Undefined index: EmailAddressTextBox in C:\Users\Jonny P\Documents\My Web Sites\JMPMySite\AddContact.php on line 17 Notice: Undefined index: AddressTextBox in C:\Users\Jonny P\Documents\My Web Sites\JMPMySite\AddContact.php on line 18 Notice: Undefined index: CityTextBox in C:\Users\Jonny P\Documents\My Web Sites\JMPMySite\AddContact.php on line 19 Notice: Undefined index: StateDropDownBox in C:\Users\Jonny P\Documents\My Web Sites\JMPMySite\AddContact.php on line 20 Notice: Undefined index: ZipTextBox in C:\Users\Jonny P\Documents\My Web Sites\JMPMySite\AddContact.php on line 21 *Please enter a First Name Again, ANY help is greatly appreciated.. it is for a class, but I have honestly exhasted all my sources to figure out what is wrong. Are my codes correct and all there? Thanks for the help! -WPN hello, I have multiple scripts I am writing for class and the very last script does not seem to be working and most of us are stumped . the first two seem to work fine but I am going to post them too just in case there is something on the previous scripts I am missing that is causing the error. the scripts are suppose to make a table then the final one lists the tables I believe. 1st script Do-Creaable.html ----------------------------------------------------------------------------------------------------------- <html> <title> input page</title> <head><strong> Name and Number of fields</strong></head> <body> <form method ="post" action="do_showfileddef.php"> Table Name: <br> <input type="text" name="table_name"><p> <br> Number of fields:<p> <input type="text" name="num_fields"><p> <input type="submit" value="go to step two"> </form> </body> </html> --------------------------------------------------------------------------------------------------------------------- second script do show_fieldeff.php --------------------------------------------------------------- <? if ((!$_POST['table_name']) || (!$_POST['num_fields'])) { header ("location: show_creatable.html"); exit; } $form_block =" <FORM METHOD=\"POST\"ACTION=\"do_creatable.php\"> <iINPUT TYPE=\"hidden\"NAME=\"table_name\" VALUE\"$_POST[table_name]\"> <TABLE CELLSPACING=5 CELLPADDING=5> <TR> <TH>field name</TH><TH>filed type</TH> <TH>field length</TH></TR>"; for($i =0; $i < $_POST['num_fields']; $i++) { $form_block .=" <tr> <td allign=center><input type=\"text\"name=\"filed_name[]\"size=\"30\"></td> <td align=center> <SELECT NAME=\"field_type[]\"> <OPTION VALUE=\"char\">char</OPTION> <OPTION VALUE=\"date\">date</OPTION> <OPTION VALUE=\"float\">float</OPTION> <OPTION VALUE=\"int\">int</OPTION> <OPTION VALUE=\"text\">textchar</OPTION> <OPTION VALUE=\"varchar\">varchar</OPTION> </SELECT> </td> <TD ALIGN=CENTER><INPUT TYPE=\"text\"NAME=\"field_length[]\" SIZE=\"5\"></td> </tr>"; } $form_block .=" <tr> <td allign=center colspan=3><input type=\"submit\"value=\"create table\"></td> </tr> </table> </form>"; ?> <html> <head> <title> create a Database table:step 2</title> </head> <body> <h1> Define fields for <? echo "$_POST[table_name]"; ?> </h1> <?echo "$form_block";?> </body> </html> ----------------------------------------------------------------------------------------------------------------- third script do_creatable.php _________________________________________________ ____________________________________ $db_name = "testdb"; $connection = @mysql_connect("localhost","root","") or die (mysql_error()); $db = @mysql_select_db($db_name,$connection) or die (mysql_error()); $sql = @"CREATE TABLE $_POST[table_name]("; for ($i =0; $i <count($_POST['field_name']);$i++){ $sql .= $_POST["field_length"][$i] ." ".$_POST['field_type'][$i]; if ($_POST ["field_length"] [$i] !="") { $sql .= "(".$_POST ["field_length"] [$i]."),"; } else { $sql .= ","; } } $sql = substr($sql,0,-1); $sql .=")"; $results = mysql_query ($sql,$connection) or die (mysql_error()); if ($results) { $msg="<P>".$_POST["table_name"]."has been created!</P>"; } ------------------------------------------------------------------------------------------------------------------ some where on that third script is an error but it keeps telling me bad syntax on line one. most of the class is having errors with this script and no one can find the cause its been like 2 weeks now. can someone help me? please bare in mind I am a student and some functions of php I am unfammiliar with I have a web site with a user login requirement that has worked splendidly for months. I also have a development version of my site on my laptop, localhost. At the moment, I have identical code on both the development and production sites. I'm getting some header error in production, but not on development. Is it guaranteed that my page is generating some white space, or is it possible that there may be another issue at hand (I'm fairly non-technical, so I'm grasping here - my web host upgraded to a different PHP version that is creating whitespace in production while development on my laptop is a different version of php, my web host has done something else that is causing this, fill in the blank with your own conspiracy theory)? Any reading material out there (besides the php.net manual) that explores what may be going on? Thanks in advance - this community has been wonderfully helpful for me over the last year! In drive.php
public function insert($postBody, $optParams = array()) Hello I am trying to only display results within the time period last sunday too next sunday. my code: Code: [Select] <?php $today = date('Y-m-d H:i:s'); $time = strtotime($today); $last_sunday = strtotime('last sunday', $time); $next_sunday = strtotime('next sunday', $time); $format = 'Y-m-d H:i:s'; $last_sunday = date($format, $last_sunday); $next_sunday = date($format, $next_sunday); ?> <?php $sql_totalsurfs = ("SELECT vtp_members.id, vtp_members.name, vtp_members.teamleader, vtp_tracking.Timber, vtp_tracking.Stone, vtp_tracking.Marble, teams.team_name, count(vtp_tracking.id) surfs FROM vtp_members, vtp_tracking, teams WHERE vtp_members.team_id=".$_GET['t']." AND vtp_tracking.credit_members_id=vtp_members.id AND vtp_tracking.action_date>'$last_sunday' AND vtp_tracking.action_date<'$next_sunday' GROUP BY vtp_members.id ORDER BY surfs DESC LIMIT 0, 10"); $rstotalsurfs = mysql_query($sql_totalsurfs); $numrows = mysql_num_rows($rstotalsurfs); ....... Is there and error somwhere in the code? I am a new developer, trying to figure out what causing a memory error. The code goes through registered appointments and depends on the service ID, I have to free a 45 minutes for another service to be booked. Now, once I book an appointment for any of the services that can have 45 minutes free spot, the website takes forever to load the hours but doesn't show them, instead I get this error A PHP Error was encountered Severity: Error Message: Maximum execution time of 120 seconds exceeded
foreach ($appointments as $appointment) { foreach ($periods as $index => &$period) { $appointment_start = new DateTime($appointment['start_datetime']); $appointment_end = new DateTime($appointment['end_datetime']); if ($appointment_start >= $appointment_end) { continue; } $period_start = new DateTime($date . ' ' . $period['start']); $period_end = new DateTime($date . ' ' . $period['end']); $serviceId=$appointment['id_services']; $color1=1; $color2=2; $color3=3; $color4=4; $color5=5; $color6=6; $color7=7; $color8=8; $color9=9; $color10=10; $color11=11; $color12=12; $color13=13; $color14=14; $color15=15; $color16=16; $color17=17; $color18=18; $color19=19; $period_s=''; $period_e=''; if ($appointment_start <= $period_start && $appointment_end <= $period_end && $appointment_end <= $period_start) { // The appointment does not belong in this time period, so we will not change anything. continue; } else { if ($appointment_start <= $period_start && $appointment_end <= $period_end && $appointment_end >= $period_start) { // The appointment starts before the period and finishes somewhere inside. We will need to break // this period and leave the available part. //open slot for services 45,45,45 if($serviceId == $color1 || $serviceId == $color3 || $serviceId == $color7 || $serviceId == $color9|| $serviceId == $color10 || $serviceId == $color11 || $serviceId == $color12){ unset($periods[$index]); $period_s= clone $appointment_start; $period_s->modify('+45 minutes'); $period_e= clone $appointment_end; $period_e->modify('-45 minutes'); $periods[] = [ 'start' => $period_s->format('H:i'), 'end' =>$period_e->format('H:i') ]; $period['start'] = $appointment_end->format('H:i'); } //Open slot for service 45,45,60 else if($serviceId == $color2 || $serviceId == $color8){ $period_s= clone $appointment_start; $period_s->modify('+45 minutes'); $period_e= clone $appointment_end; $period_e->modify('-60 minutes'); $periods[] = [ 'start' => $period_s->format('H:i'), 'end' =>$period_e->format('H:i') ]; $period['start'] = $appointment_end->format('H:i'); } // // //Open slot for service 30,45,45 else if($serviceId == $color4 || $serviceId == $color6 ||$serviceId == $color16 || $serviceId == $color18){ $period_s= clone $appointment_start; $period_s->modify('+30 minutes'); $period_e= clone $appointment_end; $period_e->modify('-45 minutes'); $periods[] = [ 'start' => $period_s->format('H:i'), 'end' =>$period_e->format('H:i') ]; $period['start'] = $appointment_end->format('H:i'); } // // //Open slot for service 30,45,60 else if($serviceId == $color5 || $serviceId == $color17){ $period_s= clone $appointment_start; $period_s->modify('+30 minutes'); $period_e= clone $appointment_end; $period_e->modify('-60 minutes'); $periods[] = [ 'start' => $period_s->format('H:i'), 'end' =>$period_e->format('H:i') ]; $period['start'] = $appointment_end->format('H:i'); } // // //Open slot for service 60,45,45 else if($serviceId == $color13 || $serviceId == $color15){ $period_s= clone $appointment_start; $period_s->modify('+60 minutes'); $period_e= clone $appointment_end; $period_e->modify('-45 minutes'); $periods[] = [ 'start' => $period_s->format('H:i'), 'end' =>$period_e->format('H:i') ]; $period['start'] = $appointment_end->format('H:i'); } // // //Open slot for service 60,45,60 else if($serviceId == $color14 ){ $period_s= clone $appointment_start; $period_s->modify('+60 minutes'); $period_e= clone $appointment_end; $period_e->modify('-60 minutes'); $periods[] = [ 'start' => $period_s->format('H:i'), 'end' =>$period_e->format('H:i') ]; $period['start'] = $appointment_end->format('H:i'); } // //for the rest of services else { $period['start'] = $appointment_end->format('H:i');} } else { if ($appointment_start >= $period_start && $appointment_end < $period_end) { // The appointment is inside the time period, so we will split the period into two new // others. unset($periods[$index]); if($serviceId == $color1 || $serviceId == $color3 || $serviceId == $color7 || $serviceId == $color9|| $serviceId == $color10 || $serviceId == $color11 || $serviceId == $color12){ $period_s= clone $appointment_start; $period_s->modify('+45 minutes'); $period_e= clone $appointment_end; $period_e->modify('-45 minutes'); $periods[] = [ 'start' => $period_start->format('H:i'), 'end' => $appointment_start->format('H:i') ]; $periods[] = [ 'start' => $period_s->format('H:i'), 'end' =>$period_e->format('H:i') ]; $periods[] = [ 'start' => $appointment_end->format('H:i'), 'end' => $period_end->format('H:i') ]; } // //Open slot for service 45,45,60 else if($serviceId == $color2 || $serviceId == $color8){ $period_s= clone $appointment_start; $period_s->modify('+45 minutes'); $period_e= clone $appointment_end; $period_e->modify('-60 minutes'); $periods[] = [ 'start' => $period_start->format('H:i'), 'end' => $appointment_start->format('H:i') ]; $periods[] = [ 'start' => $period_s->format('H:i'), 'end' =>$period_e->format('H:i') ]; $periods[] = [ 'start' => $appointment_end->format('H:i'), 'end' => $period_end->format('H:i') ]; } // // //Open slot for service 30,45,45 else if($serviceId == $color4 || $serviceId == $color6 ||$serviceId == $color16 || $serviceId == $color18){ $period_s= clone $appointment_start; $period_s->modify('+30 minutes'); $period_e= clone $appointment_end; $period_e->modify('-45 minutes'); $periods[] = [ 'start' => $period_start->format('H:i'), 'end' => $appointment_start->format('H:i') ]; $periods[] = [ 'start' => $period_s->format('H:i'), 'end' =>$period_e->format('H:i') ]; $periods[] = [ 'start' => $appointment_end->format('H:i'), 'end' => $period_end->format('H:i') ]; } // // //Open slot for service 30,45,60 else if($serviceId == $color5 || $serviceId == $color17){ $period_s= clone $appointment_start; $period_s->modify('+30 minutes'); $period_e= clone $appointment_end; $period_e->modify('-60 minutes'); $periods[] = [ 'start' => $period_start->format('H:i'), 'end' => $appointment_start->format('H:i') ]; $periods[] = [ 'start' => $period_s->format('H:i'), 'end' =>$period_e->format('H:i') ]; $periods[] = [ 'start' => $appointment_end->format('H:i'), 'end' => $period_end->format('H:i') ]; } // // //Open slot for service 60,45,45 else if($serviceId == $color13 || $serviceId == $color15){ $period_s= clone $appointment_start; $period_s->modify('+60 minutes'); $period_e= clone $appointment_end; $period_e->modify('-45 minutes'); $periods[] = [ 'start' => $period_start->format('H:i'), 'end' => $appointment_start->format('H:i') ]; $periods[] = [ 'start' => $period_s->format('H:i'), 'end' =>$period_e->format('H:i') ]; $periods[] = [ 'start' => $appointment_end->format('H:i'), 'end' => $period_end->format('H:i') ]; } // // //Open slot for service 60,45,60 else if($serviceId == $color14 ){ $period_s= clone $appointment_start; $period_s->modify('+60 minutes'); $period_e= clone $appointment_end; $period_e->modify('-60 minutes'); $periods[] = [ 'start' => $period_start->format('H:i'), 'end' => $appointment_start->format('H:i') ]; $periods[] = [ 'start' => $period_s->format('H:i'), 'end' =>$period_e->format('H:i') ]; $periods[] = [ 'start' => $appointment_end->format('H:i'), 'end' => $period_end->format('H:i') ]; } //for other services once The code is completely correct else{ $periods[] = [ 'start' => $period_start->format('H:i'), 'end' => $appointment_start->format('H:i') ]; $periods[] = [ 'start' => $appointment_end->format('H:i'), 'end' => $period_end->format('H:i') ]; } } else if ($appointment_start == $period_start && $appointment_end == $period_end) { if($serviceId == $color1 || $serviceId == $color3 || $serviceId == $color7 || $serviceId == $color9|| $serviceId == $color10 || $serviceId == $color11 || $serviceId == $color12){ unset($periods[$index]); $period_s= $appointment_start; $period_s->modify('+45 minutes'); $period_e= $appointment_end; $period_e->modify('-45 minutes'); $periods[] = [ 'start' => $period_s->format('H:i'), 'end' =>$period_e->format('H:i') ]; } //Open slot for service 45,45,60 else if($serviceId == $color2 || $serviceId == $color8){ unset($periods[$index]); $period_s= clone $appointment_start; $period_s->modify('+45 minutes'); $period_e= clone $appointment_end; $period_e->modify('-60 minutes'); $periods[] = [ 'start' => $period_s->format('H:i'), 'end' =>$period_e->format('H:i') ]; } // // //Open slot for service 30,45,45 else if($serviceId == $color4 || $serviceId == $color6 ||$serviceId == $color16 || $serviceId == $color18){ unset($periods[$index]); $period_s= clone $appointment_start; $period_s->modify('+30 minutes'); $period_e= clone $appointment_end; $period_e->modify('-45 minutes'); $periods[] = [ 'start' => $period_s->format('H:i'), 'end' =>$period_e->format('H:i') ]; } // // //Open slot for service 30,45,60 else if($serviceId == $color5 || $serviceId == $color17){ unset($periods[$index]); $period_s= clone $appointment_start; $period_s->modify('+30 minutes'); $period_e= clone $appointment_end; $period_e->modify('-60 minutes'); $periods[] = [ 'start' => $period_s->format('H:i'), 'end' =>$period_e->format('H:i') ]; } // // //Open slot for service 60,45,45 else if($serviceId == $color13 || $serviceId == $color15){ unset($periods[$index]); $period_s= clone $appointment_start; $period_s->modify('+60 minutes'); $period_e= clone $appointment_end; $period_e->modify('-45 minutes'); $periods[] = [ 'start' => $period_s->format('H:i'), 'end' =>$period_e->format('H:i') ]; } // // //Open slot for service 60,45,60 else if($serviceId == $color14 ){ unset($periods[$index]); $period_s= clone $appointment_start; $period_s->modify('+60 minutes'); $period_e= clone $appointment_end; $period_e->modify('-60 minutes'); $periods[] = [ 'start' => $period_s->format('H:i'), 'end' =>$period_e->format('H:i') ];} // //for the rest of services else { unset($periods[$index]);} // The whole period is blocked so remove it from the available periods array. } else { if ($appointment_start >= $period_start && $appointment_end >= $period_start && $appointment_start <= $period_end) { // The appointment starts in the period and finishes out of it. We will need to remove //the time that is taken from the appointment. if($serviceId == $color1 || $serviceId == $color3 || $serviceId == $color7 || $serviceId == $color9|| $serviceId == $color10 || $serviceId == $color11 || $serviceId == $color12){ unset($periods[$index]); $period_s= clone $appointment_start; $period_s->modify('+45 minutes'); $period_e= clone $appointment_end; $period_e->modify('-45 minutes'); $period['end'] = $appointment_start->format('H:i'); $periods[] = [ 'start' => $period_s->format('H:i'), 'end' =>$period_e->format('H:i') ]; } //Open slot for service 45,45,60 else if($serviceId == $color2 || $serviceId == $color8){ $period_s= clone $appointment_start; $period_s->modify('+45 minutes'); $period_e= clone $appointment_end; $period_e->modify('-60 minutes'); $period['end'] = $appointment_start->format('H:i'); $periods[] = [ 'start' => $period_s->format('H:i'), 'end' =>$period_e->format('H:i') ]; } // // //Open slot for service 30,45,45 else if($serviceId == $color4 || $serviceId == $color6 ||$serviceId == $color16 || $serviceId == $color18){ $period_s= clone $appointment_start; $period_s->modify('+30 minutes'); $period_e= clone $appointment_end; $period_e->modify('-45 minutes'); $periods[] = [ 'start' => $period_s->format('H:i'), 'end' =>$period_e->format('H:i') ]; $period['end'] = $appointment_start->format('H:i'); } // // //Open slot for service 30,45,60 else if($serviceId == $color5 || $serviceId == $color17){ $period_s= clone $appointment_start; $period_s->modify('+30 minutes'); $period_e= clone $appointment_end; $period_e->modify('-60 minutes'); $periods[] = [ 'start' => $period_s->format('H:i'), 'end' =>$period_e->format('H:i') ]; $period['end'] = $appointment_start->format('H:i'); } // // //Open slot for service 60,45,45 else if($serviceId == $color13 || $serviceId == $color15){ $period_s= clone $appointment_start; $period_s->modify('+60 minutes'); $period_e= clone $appointment_end; $period_e->modify('-45 minutes'); $periods[] = [ 'start' => $period_s->format('H:i'), 'end' =>$period_e->format('H:i') ]; $period['end'] = $appointment_start->format('H:i'); } // // //Open slot for service 60,45,60 else if($serviceId == $color14 ){ $period_s= clone $appointment_start; $period_s->modify('+60 minutes'); $period_e= clone $appointment_end; $period_e->modify('-60 minutes'); $periods[] = [ 'start' => $period_s->format('H:i'), 'end' =>$period_e->format('H:i') ]; $period['end'] = $appointment_start->format('H:i'); } // for the rest of services else{ $period['end'] = $appointment_start->format('H:i'); } } else { if ($appointment_start >= $period_start && $appointment_end >= $period_end && $appointment_start >= $period_end) { // The appointment does not belong in the period so do not change anything. continue; } else { if ($appointment_start <= $period_start && $appointment_end >= $period_end && $appointment_start <= $period_end) { //Open slot for service 45,45,45 if($serviceId == $color1 || $serviceId == $color3 || $serviceId == $color7 || $serviceId == $color9|| $serviceId == $color10 || $serviceId == $color11 || $serviceId == $color12){ unset($periods[$index]); $period_s= clone $appointment_start; $period_s->modify('+45 minutes'); $period_e= clone $appointment_end; $period_e->modify('-45 minutes'); $periods[] = [ 'start' => $period_s->format('H:i'), 'end' =>$period_e->format('H:i') ]; } //Open slot for service 45,45,60 else if($serviceId == $color2 || $serviceId == $color8){ unset($periods[$index]); $period_s= clone $appointment_start; $period_s->modify('+45 minutes'); $period_e= clone $appointment_end; $period_e->modify('-60 minutes'); $periods[] = [ 'start' => $period_s->format('H:i'), 'end' =>$period_e->format('H:i') ]; } // //Open slot for service 30,45,45 else if($serviceId == $color4 || $serviceId == $color6 ||$serviceId == $color16 || $serviceId == $color18){ unset($periods[$index]); $period_s= clone $appointment_start; $period_s->modify('+30 minutes'); $period_e= clone $appointment_end; $period_e->modify('-45 minutes'); $periods[] = [ 'start' => $period_s->format('H:i'), 'end' =>$period_e->format('H:i') ];} //Open slot for service 30,45,60 else if($serviceId == $color5 || $serviceId == $color17){ unset($periods[$index]); $period_s= clone $appointment_start; $period_s->modify('+30 minutes'); $period_e= clone $appointment_end; $period_e->modify('-60 minutes'); $periods[] = [ 'start' => $period_s->format('H:i'), 'end' =>$period_e->format('H:i') ];} // // //Open slot for service 60,45,45 else if($serviceId == $color13 || $serviceId == $color15){ unset($periods[$index]); $period_s= clone $appointment_start; $period_s->modify('+60 minutes'); $period_e= clone $appointment_end; $period_e->modify('-45 minutes'); $periods[] = [ 'start' => $period_s->format('H:i'), 'end' =>$period_e->format('H:i') ];} // // //Open slot for service 60,45,60 else if($serviceId == $color14 ){ unset($periods[$index]); $period_s= clone $appointment_start; $period_s->modify('+60 minutes'); $period_e= clone $appointment_end; $period_e->modify('-60 minutes'); $periods[] = [ 'start' => $period_s->format('H:i'), 'end' =>$period_e->format('H:i') ];} else{ unset($periods[$index]); } } } } } } } } } return array_values($periods); } Hello all,
Appreciate if you folks could pls. help me understand (and more importantly resolve) this very weird error:
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ASC, purchase_later_flag ASC, shopper1_buy_flag AS' at line 3' in /var/www/index.php:67 Stack trace: #0 /var/www/index.php(67): PDO->query('SELECT shoplist...') #1 {main} thrown in /var/www/index.php on line 67
Everything seems to work fine when/if I use the following SQL query (which can also be seen commented out in my code towards the end of this post) :
$sql = "SELECT shoplist.*, store_master.store_name, item_master.item_name FROM shoplist, store_master, item_master WHERE shoplist.store_id = store_master.store_id AND shoplist.item_id = item_master.item_id";However, the moment I change my query to the following, which essentially just includes/adds the ORDER BY clause, I receive the error quoted above: $sql = "SELECT shoplist.*, store_master.store_name, item_master.item_name FROM shoplist, store_master, item_master ORDER BY purchased_flag ASC, purchase_later_flag ASC, shopper1_buy_flag ASC, shopper2_buy_flag ASC, store_name ASC) WHERE shoplist.store_id = store_master.store_id AND shoplist.item_id = item_master.item_id";In googling for this error I came across posts that suggested using "ORDER BY FIND_IN_SET()" and "ORDER BY FIELD()"...both of which I tried with no success. Here's the portion of my code which seems to have a problem, and line # 67 is the 3rd from bottom (third last) statement in the code below: <?php /* $sql = "SELECT shoplist.*, store_master.store_name, item_master.item_name FROM shoplist, store_master, item_master WHERE shoplist.store_id = store_master.store_id AND shoplist.item_id = item_master.item_id"; */ $sql = "SELECT shoplist.*, store_master.store_name, item_master.item_name FROM shoplist, store_master, item_master ORDER BY FIND_IN_SET(purchased_flag ASC, purchase_later_flag ASC, shopper1_buy_flag ASC, shopper2_buy_flag ASC, store_name ASC) WHERE shoplist.store_id = store_master.store_id AND shoplist.item_id = item_master.item_id"; $result = $pdo->query($sql); // foreach ($pdo->query($sql) as $row) { foreach ($result as $row) { echo '<tr>'; print '<td><span class="filler-checkbox"><input type="checkbox" name="IDnumber[]" value="' . $row["idnumber"] . '" /></span></td>';Thanks Parse error: syntax error, unexpected T_STRING in C:\xampp\htdocs\mywork\unique.php on line 15 <html> <head> <title> </title> </head> <body bgproperties="fixed"> <?php $dbhost = 'localhost'; $dbuser = 'root'; $dbpass = ''; $con = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql'); $dbname = 'mywork'; mysql_select_db($dbname, $con); $sql=mysql_query(insert into users (regno,name,gender,date,month,year,emailid,cell,paddress,caddress,incometype,incomeamt,dad,fyes,dadocup,mom,myes,momocup,password) VALUES ('$_POST[regno]','$_POST[name]','$_POST[gender]','$_POST[date]','$_POST[month]','$_POST[year]','$_POST[emailid]','$_POST[cell]','$_POST[paddress]','$_POST[caddress]','$_POST[incometype]','$_POST[incomeamt]','$_POST[dad]','$_POST[fyes]','$_POST[dadocup]','$_POST[mom]','$_POST[myes]','$_POST[momocup]','$_POST[password]')"); $sql1=mysql_fetch_array($sql); $result = @mysql_query($SQl1); $result="SELECT * FROM users WHERE regno='$regno'"; while($row = mysql_fetch_array($result)) { //echo $row['regno']."regno<br>"; //echo $row['name']."name<br>"; //echo $row['gender']."gender<br>"; //echo $row['date']."date<br>"; //echo $row['month']."month<br>"; //echo $row['year']."year<br>"; //echo $row['emailid']."emailid<br>"; //echo $row['cell']."cell<br>"; //echo $row['paddress']."paddress<br>"; //echo $row['caddress']."caddress<br>"; //echo $row['incometype']."incometype<br>"; //echo $row['incomeamt']."incomeamt<br>"; //echo $row['dad']."dad<br>"; //echo $row['fyes']."fyes<br>"; //echo $row['dadocup']."dadocup<br>"; //echo $row['mom']."mom<br>"; //echo $row['myes']."myes<br>"; //echo $row['momocup']."momocup<br>"; //echo $row['password']."password<br>"; } echo "Thanks for Register!"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } echo "1 record added"; mysql_close($con); ?> <form name="security" action="index.php" method="post"> <input type="submit" value="click here to login"> </form> </body> </html> Code: [Select] <?php mysql_connect ("-","-","-") or die ('Error'); mysql_select_db ("-"); $out = mysql_query("SELECT * FROM guestbook ORDER BY id DESC"); while($row = mysql_fetch_assoc($out); --and this one if that braces is deleted { ----this is where im getting the error $name = $row['name']; $email = $row['email']; $txt = $row['comment']; $msg = "Are you sure you want to delete"; /* @var $_REQUEST <type> */ if (isset($_REQUEST ["action"]) && $_REQUEST["action"] == "del") { $id = intval($_REQUEST['id']); mysql_query("DELETE FROM guestbook WHERE id=$id;"); echo "<action=index.php>"; } echo "<font face='verdana' size='1'>"; echo "<table border='0'> <tr><td>Name: ".$name."</td></tr>"." <tr><td>Email: ".$email."</td></tr> <tr><td colspan='2'>Comment:</td></tr> <tr><td colspan='2' width='500'><b>".$txt."</b></td></tr> <tr><td><a onclick=\"return confirm('.$msg.');\" href='index.php?action=del&id=".$row['id']."'><span class='red'>["."Delete"."]</span></a> </td></tr> </table><br />"; echo "<hr size='1' width='500' align='left'></font>"; } ?> Kindly help me please. When i delete ({) the error will become the ( i dont know what to do already. Thanks. $BoxSize = array("smallbox" = array("length" => 12, "width" => 10, "depth" => 2.5), "mediumbox" = array("length" => 30, "width" => 20, "depth" => 4), "largebox" = array("length" => 60, "width" => 40, "depth" => 11.5)); Folks, I remember once having a php or html5 issue where the first option had to be blank in the drop down. Otherwise, it wasn't working. What wasn't working ? How wasn't working ? I can't remember. either php had difficulty reading user input or the drop down was not showing any options. And so, I had to add a blank value. So, something like this wasn't working ...
<label for="tos_agreement">Agree to TOS or not ?</label> <select name="tos_agreement" id="tos_agreement"> <option value="yes">Yes</option> <option value="no">No</option> </select>
And, I think I added a blank value, at somebody's advice, to get it to work. I think it was something like this, if I remember correctly:
<label for="tos_agreement">Agree to TOS or not ?</label> <select name="tos_agreement" id="tos_agreement"> <option value=" ">Select here</option> <option value="yes">Yes</option> <option value="no">No</option> </select>
Or, maybe it was something like this:
<label for="tos_agreement">Agree to TOS or not ?</label> <select name="tos_agreement" id="tos_agreement"> <option value=" "></option> <option value="yes">Yes</option> <option value="no">No</option> </select>
I can't remember. All I remember slightly that there was a blank value. I been going through my php files to find that particular file to jog my memory but I failed to find it. Can you folks explain to me if a blank value is required or not ? What is the benefit/disaster of adding it and how should the blank value be added ? Show me an example.
Was this a php or html 5 issue ? Can anybody fugure ?
Thank You |