PHP - Another Small Issue - Select Error
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? Similar TutorialsHi Guys, I have a small issue with a new php script I wrote. It works fine, except for one issue. When the scrip emails me the info it captures, I need it to have the email sent to me from the person filling out the form. i.e. from the email address located in the $email field. It does not. Here's the code. (domain.com is just a dummy name to hold the spot, obviously.) <?php /* Subject and email */ $emailSubject = 'Centre Street Registration'; $webMaster = 'email@domain.com'; /* Gathering Data */ $firstname = $_POST['FirstName']; $lastname = $_POST['LastName']; $email = $_POST['Email']; $daytime = $_POST['Daytime']; $home = $_POST['Home']; $citytown = $_POST['CityTown']; $movingwhen = $_POST['MovingWhen']; $hearofus = $_POST['HearofUs']; $contactmethod = $_POST['ContactMethod']; $squareft = $_POST['SqareFt']; $important = $_POST['Important']; $pricerange = $_POST['PriceRange']; $body = <<<EOD First Name: $firstname Last Name: $lastname Email: $email Daytime Number: $daytime Home Number: $home City: $citytown Moving When: $movingwhen Hear of Us: $hearofus Contact Method: $contactmethod Square Feet: $squareft Important to You: $important Price Range: $pricerange Excel Data: $firstname,$lastname,$email,$daytime,$home,$citytown,$movingwhen,$hearofus,$contactmethod,$squareft,$important,$pricerange EOD; $headers = "From: $email"; $headers .= "Conten-type: text/html"; $success = mail($webMaster, $emailSubject, $body); /* Results rendered as HTML */ /* $theResults = 'domain.com'; */ header( "Location: http://www.dommain.com/thankyou_centre.shtml" ); ?> I'm using a wordpress theme which comes with a zoom feature for the product (main image and image gallery thumbnails). It currently opens the primary image (and any thumbnail) in a modal window which is quite ugly for a product showcase. Code is: Code: [Select] $imgtag = '<img src="'.$src.'"'.$titleattr.' alt="'.$alt.'" width="'.$width_a.'" height="'.$height_a.'" '.$classes.' />'; if (value_is_true($zoom)) return '<a href="'.ecarturl($img->id,'images').'/'.$img->filename.'" class="'.$zoomfx.'" rel="product-'.$this->id.'">'.$imgtag.'</a>'; I'm trying to implement Cloudzoom (http://www.professorcloud.com/mainsite/cloud-zoom-integration.htm) I changed the code to: Code: [Select] $imgtag = '<a href="'.ecarturl($img->id,'images').'/'.$img->filename.'" class = "cloud-zoom" id="zoom1" rel="adjustX: 10, adjustY:-4, zoomWidth:150, zoomHeight:150, position:\'inside\'"> <img src="'.$src.'"'.$titleattr.' alt="'.$alt.'" width="'.$width_a.'" height="'.$height_a.'" '.$classes.' /></a>'; if (value_is_true($zoom)) return '<a href="'.ecarturl($img->id,'images').'/'.$img->filename.'" class="cloud-zoom-gallery" rel="useZoom: \'zoom1\'">"'.$imgtag.'</a>'; HTML Output: Code: [Select] <div id="main-picture-default"> <a href="http://www.url.com?siid=9/2-9202.jpg" class = "cloud-zoom" id="zoom1" rel="adjustX: 10, adjustY:-4, zoomWidth:150, zoomHeight:150, position:'inside'"> <img src="http://www.url.com?siid=9&360,450,1,100,2441305929" alt="product-picture" width="360" height="450" /></a> </div> <div id="thumbs"> <ul id="thumbs-list-default"> <li class="one_third "><a href="http://www.url.com?siid=9/2-9202.jpg" class="cloud-zoom-gallery" rel="useZoom: 'zoom1'">“<a href="http://www.url.com?siid=9/2-9202.jpg" class = "cloud-zoom" id="zoom1" rel="adjustX: 10, adjustY:-4, zoomWidth:150, zoomHeight:150, position:'inside'"> <img src="http://www.url.com?siid=9&64,64,1,452849676" alt="thumb" width="64" height="64" class="thumb-picture" /></a></a></li> <li class="one_third "><a href="http://www.url.com?siid=17/2-9203.jpg" class="cloud-zoom-gallery" rel="useZoom: 'zoom1'">“<a href="http://www.url.com?siid=17/2-9203.jpg" class = "cloud-zoom" id="zoom1" rel="adjustX: 10, adjustY:-4, zoomWidth:150, zoomHeight:150, position:'inside'"> <img src="http://www.url.com?siid=17&64,64,1,1330882420" alt="thumb" width="64" height="64" class="thumb-picture" /></a></a></li> </ul> The primary image zooms just fine. The trouble I have now caused is as follows: - On hovering the thumbnails, they automatically zoom. They shouldn't. Rather on clicking them it should change the primary image to that image. - There is a " on the page above each thumbnail which links to the thumbnail images bigger image, and on click it shows "loading" on the primary image but doesn't actually change the image. How can I fix my code to work the way the script works he http://www.professorcloud.com/mainsite/cloud-zoom-test.htm, so the thumbnail changes the primary image and the zoom doesn't occur on the thumbnail, only the primary image? Thanks! Note: Would changing the last line `'.$imgtag.'` to `'.ecarturl($img->id,'images').'/'.$img->filename.'` be the fix? Don't want to try it before I get confirmation Hello all, I'm designing an upload file section for a home medical company. So far it has been going great, I am uploading files and they're being successfully inserted into my MYSQL Table. However, my issue is when I download the files they claim to be corrupted and unusable. If I save the PDF files to my desktop they won't open at all, they claim to be corrupted. If I download a JPG and then open it in photshop it warns me the file may be corrupted, knowing it is not I clicked "yes". The jpg actually opens and looks like the image, however about 50 pixels on the bottom get cut off and look like a messy TV screen, if that makes sense. Wondering if anyone has had this similar issue, the uploading part is not the issue - just downloading the files. My Upload Form Code: Code: [Select] <p><a href="upload.php">Upload a File</a> <a href="../admin/admin.php">Back to Control Panel</a></p> <form action="add_file.php" method="post" enctype="multipart/form-data"> <input type="file" name="uploaded_file"><br> <input type="submit" value="Upload file"> </form> <p> <a href="list_files.php">See all files</a> </p> My Add File Code (This is working fine but may cause issues with downloading?) Code: [Select] <?php // Check if a file has been uploaded if(isset($_FILES['uploaded_file'])) { // Make sure the file was sent without errors if($_FILES['uploaded_file']['error'] == 0) { // Connect to the database $dbLink = new mysqli('localhost', 'vzimbel_user', 'webdesign1', 'vzimbel_db'); if(mysqli_connect_errno()) { die("MySQL connection failed: ". mysqli_connect_error()); } // Gather all required data $name = $dbLink->real_escape_string($_FILES['uploaded_file']['name']); $mime = $dbLink->real_escape_string($_FILES['uploaded_file']['type']); $data = $dbLink->real_escape_string(file_get_contents($_FILES ['uploaded_file']['tmp_name'])); $size = intval($_FILES['uploaded_file']['size']); // Create the SQL query $query = " INSERT INTO `file` ( `name`, `mime`, `size`, `data`, `created` ) VALUES ( '{$name}', '{$mime}', {$size}, '{$data}', NOW() )"; // Execute the query $result = $dbLink->query($query); // Check if it was successfull if($result) { echo 'Success! Your file was successfully added!'; } else { echo 'Error! Failed to insert the file' . "<pre>{$dbLink->error}</pre>"; } } else { echo 'An error accured while the file was being uploaded. ' . 'Error code: '. intval($_FILES['uploaded_file']['error']); } // Close the mysql connection $dbLink->close(); } else { echo 'Error! A file was not sent!'; } // Echo a link back to the main page echo '<p>Click <a href="upload.php">here</a> to go back</p>'; ?> My List File Code (This is working fine also, but does contain the link that I click when I want to download a file) Code: [Select] <?php $dbLink = new mysqli('localhost', 'vzimbel_user', 'webdesign1', 'vzimbel_db'); if(mysqli_connect_errno()) { die("MySQL connection failed: ". mysqli_connect_error()); } // Query for a list of all existing files $sql = 'SELECT `id`, `name`, `mime`, `size`, `created` FROM `file`'; $result = $dbLink->query($sql); // Check if it was successfull if($result) { // Make sure there are some files in there if($result->num_rows == 0) { echo '<p>There are no files in the database</p>'; } else { // Print the top of a table echo '<table width="100%"> <tr> <td><b>Name</b></td> <td><b>Mime</b></td> <td><b>Size (bytes)</b></td> <td><b>Created</b></td> <td><b> </b></td> </tr>'; // Print each file while($row = $result->fetch_assoc()) { echo " <tr> <td>{$row['name']}</td> <td>{$row['mime']}</td> <td>{$row['size']}</td> <td>{$row['created']}</td> [u][b]<td><a href='get_file.php?id={$row['id']}'>Download</a></td>[/b][/u] </tr>"; } // Close table echo '</table>'; } // Free the result $result->free(); } else { echo 'Error! SQL query failed:'; echo "<pre>{$dbLink->error}</pre>"; } // Close the mysql connection $dbLink->close(); ?> And here is my Get File page. This is where my problem lies. (I think) Code: [Select] <?php // Make sure an ID was passed if(isset($_GET['id'])) { // Get the ID $id = intval($_GET['id']); // Make sure the ID is in fact a valid ID if($id <= 0) { die('The ID is invalid!'); } else { // Connect to the database $dbLink = new mysqli('localhost', 'vzimbel_user', 'webdesign1', 'vzimbel_db'); if(mysqli_connect_errno()) { die("MySQL connection failed: ". mysqli_connect_error()); } // Fetch the file information $query = " SELECT `mime`, `name`, `size`, `data` FROM `file` WHERE `id` = {$id}"; $result = $dbLink->query($query); if($result) { // Make sure the result is valid if($result->num_rows == 1) { // Get the row $row = mysqli_fetch_assoc($result); // Print headers header("Content-Type: ". $row['mime']); header("Content-Length: ". $row['size']); header("Content-Disposition: attachment; filename=". $row['name']); // Print data echo $row['data']; } else { echo 'Error! No image exists with that ID.'; } // Free the mysqli resources @mysqli_free_result($result); } else { echo "Error! Query failed: <pre>{$dbLink->error}</pre>"; } @mysqli_close($dbLink); } } else { echo 'Error! No ID was passed.'; } ?> Thanks for any help that anyone can provide, this issue is really causing some stress and hurting my sleep at night! Can't figure out why this won't work, it's literally the last step in completing this website. Please let me know if you need any other information regarding this issue. Thanks, - Mike it says i have an error in in line 23 which is i cant seem to find it Code: [Select] <?php if($_POST['loginbtn']){ require "scripts/connect.php"; $email = mysql_real_escape_string($_POST['email']); $password = mysql_real_escape_string($_POST['password']); if($email && $password){ $password = md5("$password"); $query = mysql_query("SELECT * FROM ezadmin WHERE email = '$email'"); $numrows = mysql_num_rows($query); if($numrows != 0){ $row = mysql_fetch_assoc($query); //line 23 $dbemail = $row ['email']; $dbpassword = $row ['password']; if($dbemail === $email && $dbpassword === $password){ $_SESSION['email'] = $dbemail; header("location: adminpanel"); exit(); }else $msg = "PLEASE CHECK YOU EMAIL OR PASSWORD!"; }else $msg = "PERSON DOES NO EXSIT!"; }else $msg = "YOU MUST FILL IN ALL FIELDS!"; mysql_close(); } ?> i am using a php mail scriot which is perfectly sending emails... Code: [Select] <?php require("class.phpmailer.php"); // path to the PHPMailer class $to=$_POST['email']; $msg='<html> <body><h1>My HTML Message</h1> <p>This is text</p> </body> </html>'; $sub=$_POST['sub']; $mail = new PHPMailer(); $mail->IsSMTP(); // telling the class to use SMTP $mail->Mailer = "smtp"; $mail->Host = "mail.mydomain.com"; //$mail->Port = 587; $mail->SMTPAuth = true; // turn on SMTP authentication $mail->Username = "user@mydomain.com"; // SMTP username $mail->Password = "password"; // SMTP password $file = './abc.txt'; // attachment $mail->addAttachment('./attachment.jpeg'); $mail->From = "USER"; $mail->AddAddress("$to"); $mail->Subject = "$sub"; $mail->Body = "$msg"; $mail->WordWrap = 50; if(!$mail->Send()) { echo 'Message was not sent.'; echo 'Mailer error: ' . $mail->ErrorInfo; } else { echo 'Message has been sent.'; } } ?> Every thing is working fine.. But when i paste any html thing in the $msg variable i got just the source code... Any assistance will be very helpfull... -pranshu.a.11@gmail.com Below is my code that is suppose to insert and show records from database using ajax.
Retrieving the records from the database works. However it won't insert a record. I do not get any errors. The page simply refreshes when I hit submit button.
Can you see what might be wrong in my code?
index.php
<script> $(document).ready(function(){ function showComment(){ $.ajax({ type:"post", url:"process.php", data:"action=showcomment", success:function(data){ $(".wrapper").html(data); } }); } showComment(); $("#submit").click(function(){ var name=$("#name").val(); var message=$("#details").val(); $.ajax({ type:"post", url:"process.php", data:"name="+name+"&details="+message+"&action=addcomment", success:function(data){ showComment(); } }); }); }); </script> $id = $_GET['id']; $title = $_GET['title']; $_SESSION['id'] = $id; $_SESSION['title'] = $title; <div class="wrapper"></div> <form action="" method="post" enctype="multipart/form-data"> <div class="newfield"> <label for="title">Name <span class="highlight">*</span></label> <input id="name" type="text" name="name"> </div> <div class="newfield"> <label for="details">Details <span class="highlight">*</span></label> <textarea id="details" name="details""></textarea> </div> <input type="submit" name="submit" id="submit" value="Submit Tale"> </form>process.php <?php require_once '/core/init.php'; $id = $_SESSION['id']; $action = $_POST['action']; if($action == 'showcomment') { try { $get = $db->prepare("SELECT * FROM sub_posts WHERE id = :id"); $get->bindParam('id', $id); $get->execute(); $getStmt = $get->fetchAll(PDO::FETCH_ASSOC); if(count($getStmt) > 0) { foreach($getStmt as $row) { $new_name = $row['name']; $new_details = $row['details']; ?> <ul> <li> <?php echo $new_name; ?> </li> <li> <?php echo $new_details; ?> </li> </ul> <?php } } else { // no records found. } } catch(Exception $e) { die($e->getMessage()); } } else if($action == 'addcomment') { $name = $_GET['name']; $details = $_GET['details']; try { $insert = $db->prepare("INSERT INTO sub_posts(id, name, details) VALUES(:id, :name, :details)"); $insert->bindParam('id', $id); $insert->bindParam('name', $name); $insert->bindParam('details', $details); $insert->execute(); if($insert == false){ echo 'record could not be inserted.'; } else { echo 'record has been inserted.'; } } catch(Exception $e) { die($e->getMessage()); } } else { echo 'no results.'; } Edited by helloworld001, 20 December 2014 - 05:18 PM. I was trying to access my files in a folder i have to further manipulate them but i am havin the following error Warning: opendir(C: mpp\htdocs\j) [function.opendir]: failed to open dir: No such file or directory in C:\xampp\htdocs\re_name.php on line 3 Warning: readdir() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\re_name.php on line 5 filename : ( and the loop keeps on rolling down) my code is $dir = "C:\xampp\htdocs\j"; $file_open = opendir($dir); while(($file = readdir($file_open)) !== FALSE) { echo "filename : ".$file."<br />"; } closedir($file_open); i do not understand wer am i creating the mistake!! Hi there, just trying to make my while loop for echoing data look better but ive now got an error: Parse error: syntax error, unexpected T_STRING in /home/a9855336/public_html/261/cadetinfo.php on line 48 and im not sure what ive done wrong here is my code, line 48 is marked <?php $fldtextArea_name = str_replace("<br>", "\n", $fldtextArea_name); //connect to the databas mysql_connect("m*******","a********_root","n*********"); mysql_select_db("m***********"); //add the email to from @valiantflight.co.uk $from = $from."@valiantflight.co.uk"; //query database and pull email addresses $result = mysql_query("SELECT * FROM mail"); while ($row = mysql_fetch_array($result)) { ?> 48 <div id="rightleft"><?php echo('Name:'. $row['Name'] .'); ?></div><div id="rightright"><?php echo('Email:'. $row['Email'] .'<br>'); ?></div> <?php } ?> Any help would be very appriciated, Thanks, Blink359 My Error Output is this: Warning: Cannot modify header information - headers already sent by (output started at city-search.php:1) in city-search.php on line 65 What I'm I missing in the code, I can't seem to get these. It works excellent in Localhost, but in production. Error above. Code: [Select] <?php // MG CREATED THIS SIMPLE REGISTRATION PHP FOR THAT GOES TO ONE SPECIFIC USER. // WILL TEST FORM REGSITRATION NG 07-2011 //If the form is submitted if(isset($_POST['submit'])) { //Check to make sure that the name field is not empty if(trim($_POST['name']) == '') { $hasError = true; } else { $name = trim($_POST['name']); } //Check to make sure that the subject field is not empty if(trim($_POST['subject']) == '') { $hasError = true; } else { $subject = trim($_POST['subject']); } //Check to make sure sure that a valid email address is submitted if(trim($_POST['email']) == '') { $hasError = true; } else if (!eregi("^[A-Z0-9._%-]+@[A-Z0-9._%-]+\.[A-Z]{2,4}$", trim($_POST['email']))) { $hasError = true; } else { $email = trim($_POST['email']); } //Check to make sure comments were entered if(trim($_POST['message']) == '') { //$hasError = true; $comments == 'Have No Friends'; } else { if(function_exists('stripslashes')) { $comments = stripslashes(trim($_POST['message'])); } else { $comments = trim($_POST['message']); } } //If there is no error, send the email if(!isset($hasError)) { //$emailTo = 'regina@shushmedeals.com'; //$emailTo = 'reginabyrd32@yahoo.com'; $emailTo = 'mp3@danjaproduction.com'; //$emailBcc = 'ganja99@netzero.net'; //$emailBcc = 'info@danjaproduction.com'; //$emailBcc = 'ganja99@netzero.net'; //Put your own email address here $body = "Location: $name \n\nEmail: $email \n\nShushMeDeals Sign-up Info:\n $comments"; // To send HTML mail, the Content-type header must be set $headers = 'From: ShushMeDeals.com City Location sign-up - '.$name.'' . "\r\n" . 'Reply-To: ' . $email . "\r\n" .'Bcc: print@extremeatlanta.com'; //$headers .= 'Cc: birthdayarchive@example.com' . "\r\n"; //$headers .= 'Bcc: info@danjaproduction.com' . "\r\n"; mail($emailTo, $subject, $body, $headers); $emailSent = true; if($emailSent = true) { setcookie("location", $name); //echo '<script type="text/javascript"> // window.location = "index.php?option=com_enmasse&controller=deal&task=today&locationName='.$name.'" // </script>'; } } } ?> Okay, I have no idea how this works out but this is really getting on my nerves. Here is my logic for the following code. I manually register a user, It goes into the database and dispatches an email notification explaining that a user must activate their account and change their user name (OPTIONAL) and password. In the email, There is an automatically generated password with the username, And a link to activate the account. This leads to stage 1 of the activation process, In this stage the user is accepted, Registered as a verified user and then is sent to another page to change the details like login and password. As far as I know this page works except through trial and error I found that this little snippet of code is causing browsers to show an error 500 page, If I remove this the page works: <?php if($messages){ displayErrors($messages); } else { echo("<p align=\"center\" class=\"standard\">Your account has been activated.</p><p align=\"center\" class=\"standard\">You now need to change your password. If you like you can also change your username, Remember that you only have 3 days to do so and this change will be permanent.</p>"); } ?> and this is the displayErrors function: <?php function displayErrors($messages) { print("<p align=\"center\" class=\"standard\">"."<b>There were problems with the previous action:</b>\n<ul>\n"); foreach($messages as $msg){ print("<li>$msg</li>\n"); } print("</ul>\n"."</p>"); } ?> The displayErrors function is in a file called functions.php, Which is included in config.php, Which is included in every page including this one. The entire "Change password and login page thingie" is he <?php include("config.php"); global $link, $messages; require_once('recaptchalib.php'); if($_GET['error']){ $id=$_GET['id']; $messages[]="There is more than one or no accounts with the verification code you are using. <a href=\"mailto:rentals@nivso.co.uk?subject=Two or no accounts with activation ID of $id\">Click here to email us about this and have the problem sorted.</a>"; doIndex(); exit; } if(isset($_POST['submit'])){ if(!isset($_POST['activationid'])){ die("Doesn't exist -.- might as well quit this is *STUFF* -.-"); } $privatekey = "YOUR NOT HAVING THIS"; $resp = recaptcha_check_answer ($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]); if (!$resp->is_valid) { $messages[]="The code you entered is incorrect. Please go back and try again!"; doIndex(); exit; // exit or the below lines will be processed. } else { //This is where the fun starts! $login=$_POST['login']; $passw=$_POST['password']; $passc=$_POST['passwordc']; $id2=$_POST['activationid']; $changinglogin=false; $get1=excDB("SELECT * FROM `users` WHERE `activeID`='$id2'"); if($get1[0]){ $get1=$get1[1]; } else { die($get1[2]); } $pro1=mysql_fetch_array($get1); if($pro1['login']!=$login){ $changinglogin=true; field_validator("Login", $login, "alphanumeric", 4, 15); } field_validator("Password", $passw, "string", 6, 20); if($passw!=$passc){ $messages[]="The passwords do not match, Please make sure that the passwords are the same!"; } if($messages){ doIndex(); exit; } $passcl=mysql_escape_string($passw); $passen=md5($passcl); if($changinglogin){ $wri1=excDB("UPDATE `users` SET `login`='$login', `password`='$passen', `passchange`='1', `loginchange`='1' WHERE `activeID`='$id2';"); if($wri1[0]){ $wri1=$wri1[1]; } else { die($wri1[2]); } header("Location: login.php?created"); } else { $wri1=excDB("UPDATE `users` SET `password`='$passen', `passchange`='1', `loginchange`='0' WHERE `activeID`='$id2';"); if($wri1[0]){ $wri1=$wri1[1]; } else { die($wri1[2]); } header("Location: login.php?created2"); } } } else { doIndex(); } function doIndex(){ ?> <!DOCTYPE html> <head> <title>Family Rental System! - Rent your DVDs here - Design by Alex, Coding by Gergy008</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link type="text/css" href="css/main.css" rel="stylesheet"> <style type="text/css"> <!-- body { background-color: #333333; } --> </style></head> <body style="text-align:center;"> <div class="first"> <div class="backgrounder1"></div> <div class="headerbar1"></div> <div class="headerbar2"></div> </div> <div align="center"> <table border="0" cellpadding="0" cellspacing="0" width="900"> <tr> <td><img src="images/spacer.gif" width="52" height="1" border="0" alt="" /></td> <td><img src="images/spacer.gif" width="123" height="1" border="0" alt="" /></td> <td><img src="images/spacer.gif" width="352" height="1" border="0" alt="" /></td> <td><img src="images/spacer.gif" width="33" height="1" border="0" alt="" /></td> <td><img src="images/spacer.gif" width="55" height="1" border="0" alt="" /></td> <td><img src="images/spacer.gif" width="110" height="1" border="0" alt="" /></td> <td><img src="images/spacer.gif" width="110" height="1" border="0" alt="" /></td> <td><img src="images/spacer.gif" width="50" height="1" border="0" alt="" /></td> <td><img src="images/spacer.gif" width="15" height="1" border="0" alt="" /></td> <td><img src="images/spacer.gif" width="1" height="1" border="0" alt="" /></td> </tr> <tr> <td colspan="9" background="images/template.slice.1.png"> </td> <td><img src="images/spacer.gif" width="1" height="20" border="0" alt="" /></td> </tr> <tr> <td colspan="5" background="images/template.slice.2.png"> </td> <td colspan="2" rowspan="2" background="images/template.slice.3.png"><span class="login"><?php echo(loginHandler()); ?></span></td> <td colspan="2" rowspan="3" background="images/template.slice.4.png"> </td> <td><img src="images/spacer.gif" width="1" height="30" border="0" alt="" /></td> </tr> <tr> <td rowspan="8" background="images/template.slice.5.png"> </td> <td colspan="2" background="images/template.slice.6.png"><form> <div align="center"> <input name="textfield" type="text" id="textfield" size="40" style="height:16px;"> <input type="submit" name="button" id="button" value="Search" style="height:20px;"> </div> </form></td> <td colspan="2" rowspan="2" background="images/template.slice.7.png"> </td> <td><img src="images/spacer.gif" width="1" height="30" border="0" alt="" /></td> </tr> <tr> <td colspan="2" rowspan="3" background="images/template.slice.8.png"><p> </p> <p> </p></td> <td colspan="2" background="images/template.slice.9.png"> </td> <td><img src="images/spacer.gif" width="1" height="70" border="0" alt="" /></td> </tr> <tr> <td rowspan="2" background="images/template.slice.10.png"> </td> <td colspan="4" background="images/template.slice.11.png"> </td> <td rowspan="6" background="images/template.slice.12.png"> </td> <td><img src="images/spacer.gif" width="1" height="30" border="0" alt="" /></td> </tr> <tr> <td colspan="4" background="images/template.slice.13.png"></td> <td><img src="images/spacer.gif" width="1" height="8" border="0" alt="" /></td> </tr> <tr> <td rowspan="4" background="images/template.slice.14.png"> </td> <td colspan="4" background="images/template.slice.15.png"> </td> <td colspan="2" rowspan="4" background="images/template.slice.16.png"> </td> <td><img src="images/spacer.gif" width="1" height="35" border="0" alt="" /></td> </tr> <tr> <td colspan="4" background="images/template.slice.17.png"> </td> <td><img src="images/spacer.gif" width="1" height="37" border="0" alt="" /></td> </tr> <tr> <td colspan="4" align="center" valign="top" background="images/template.slice.18.png" style="vertical-align:top;"><p class="standard"> </p> <table width="80%" border="0"> <tr> <td colspan="2"> <?php if($messages){ //displayErrors($messages); } else { //echo("<p align=\"center\" class=\"standard\">Your account has been activated.</p><p align=\"center\" class=\"standard\">You now need to change your password. If you like you can also change your username, Remember that you only have 3 days to do so and this change will be permanent.</p>"); ?></td> </tr> <form name="ChangeDetails" method="post" action="<?=$_SERVER['PHP_SELF']?>"> <input type="hidden" name="activationid" value="<?php if($_GET['id']){ $id=$_GET['id']; echo($id); } elseif($_POST['activationid']){ $id=$_POST['activationid']; echo($id); } else { die("No ID") } ?>" /> <tr> <td width="50%"><div align="right" class="standard">New Username: </div></td> <td width="50%"><input name="login" type="text" id="login" size="35" maxlength="30" /></td> </tr> <tr> <td><div align="right" class="standard">New Password:</div></td> <td><input name="password" type="password" id="password" size="35" maxlength="30" /></td> </tr> <tr> <td><div align="right" class="standard">Re-enter password:</div></td> <td><input name="passwordc" type="password" id="passwordc" size="35" maxlength="30" /></td> </tr> <tr> <td><div align="right" class="standard">Please enter the code: </div></td> <td> <?php require_once('recaptchalib.php'); $publickey = "6Le4fsESAAAAAKMOHb8aaiyDfGRJyr0y0EU7dXm-"; // you got this from the signup page echo recaptcha_get_html($publickey); ?> </td> </tr> <tr> <td> </td> <td><input type="submit" name="submit" id="submit" value="Change your details" /></td> </tr> </form> </table> </td> <td><img src="images/spacer.gif" width="1" height="450" border="0" alt="" /></td> </tr> <tr> <td colspan="4" background="images/template.slice.19.png"> </td> <td><img src="images/spacer.gif" width="1" height="50" border="0" alt="" /></td> </tr> <tr> <td colspan="9" background="images/template.slice.20.png"> </td> <td><img src="images/spacer.gif" width="1" height="40" border="0" alt="" /></td> </tr> </table> </div> </body> </html> <?php } ?> Thanks to all you kind people that take your time to read and help me with this problem. I'm sorry if it is a really simple problem I missed out that makes me look like a right idiot and wasted your time, but that's me I'm always missing stuff out like that, I do proof read though just sometimes not good enough. Thanks in advance! please can you help .. I'm passing a value from another page using $_SESSION and trying to then use it in a SELECT statement in SQL think I'm missing something ... if hard code the value it works , and I have also checked at the other end that the variable is being assigned ...
code is (its the = $_SESSION['g_district'] "); that's causing the issue
I'm getting Parse error: syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting '-' or identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING) in /Applications/XAMPP/xamppfiles/htdocs/mytimekeeper/add/add.php on line 170 in the browser <div class="row s2 m2 l2"> <div> <label for="course_id">Choose the course raced:</label> <select name="course_id"> <?php // query to create course_id dropdown $resultset = $conn->query("SELECT `course_id`,`course_name` FROM `tbl_courses` WHERE `district`= $_SESSION['g_district'] "); while($row = $resultset->fetch_assoc()) { echo "<option value='{$row[course_id]}'>{$row['course_name']}</option>"; } ?> </select>
I'm trying to figure out some pagination on a left joined query, and not having any luck. The query seems to be pulling the entire database, so I went into the query's WHERE and added the table name "descriptors." Now I'm getting this error with the below query: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /data/21/2/40/160/2040975/user/2235577/htdocs/leafsearch4.php on line 35 also: Unknown column 'descriptors.leaf_shape' in 'where clause' I thought this was syntax, but maybe I'm missing something. Code: [Select] $query = "SELECT COUNT(*) as num FROM descriptors LEFT JOIN plantae ON (descriptors.plant_id = plantae.plant_name) WHERE `descriptors.leaf_shape` LIKE '%$select1%' AND `descriptors.leaf_venation` LIKE '%$select3%' AND `descriptors.leaf_margin` LIKE '%$select4%'"; $total_pages = mysql_fetch_array(mysql_query($query)); Hello: I am trying to select all the records from a table, and display them. Having an issue... This is the code: Code: [Select] <ul> <?php $query = mysql_query("SELECT id,mySectionTitle FROM myWebSiteData"); while($menuData = mysql_fetch_array($query)) { <li><a href="a_websiteData.php?id=" .echo $menuData['id'] ."">echo $menuData['mySectionTitle']</a></li> } ?> </ul> This is the error: Code: [Select] Parse error: syntax error, unexpected '<' in /html/admin/a_websiteData.php on line 91 line 91 is the one that starts with "<li>" What am I missing, or what would be the best way to do this? I have searched this forum as well as over 200 other forums and have not found the answer that is specific to my question. I have shortened my code drastically to assist in resolving this quickly -
I have a search form that has criteria for the search criteria with "virtual" "columns" in an array but it's not working. If I search one column at a time it works just fine but when I try to search 8 columns with one select I get the following error: SELECT Error: Unknown column 'achievements' in 'where clause'.
When a user selects search in Achievements, I need it to look at all 8 columns that are associated with achievements and bring back the results that match - the same as if the user selects search in Associations, I need it to look at all 5 columns and bring back the results that match.
My shortened code is as follows:
<!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 http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Search</title> </head> <body> <form name="search" action="" method="POST"> <p>Search:</p> <p> Achievements/Associations: <input type="text" name="find1" /> in <Select NAME="field1"> <Option VALUE="achievements">Achievements</option> <Option VALUE="associations">Associations</option> </Select> <br><br> Secondary Education: <input type="text" name="find2" /> in <Select NAME="field2"> <Option VALUE="edu1sectype">Highest Certificate Attained</option> <Option VALUE="edu1secname">Highest Grade Passed</option> <Option VALUE="edu1secinst">Name of High School</option> <Option VALUE="edu1secdate">Date Completed</option> <Option VALUE="edu1secinsttyp">Type of Institution</option> <Option VALUE="subjects">Subjects</option> </Select> <br><br> <input type="hidden" name="searching" value="yes" /> <input type="submit" name="search" value="Search" /> </p> </form> <?php $searching = $_POST['searching']; $find1 = $_POST['find1']; $field1 = $_POST['field1']; $find2 = $_POST['find2']; $field2 = $_POST['field2']; if ($searching =="yes") { echo "<br><b>Searched For:</b> $find1 $find2<br>"; echo "<br><h2>Results</h2><p>"; //If they did not enter a search term we give them an error // Otherwise we connect to our Database include_once "connect_to_mysql.php"; mysql_select_db("table_name") or die(mysql_error()); // We preform a bit of filtering $find = strtoupper($find); $find = strip_tags($find); $find = trim($find); $find = mysql_real_escape_string($find); $field = mysql_real_escape_string($field); $data = mysql_query("SELECT * FROM table_name WHERE upper(".$field1.") LIKE '%$find1%' AND upper(".$field2.") LIKE '%$find2%' ") or die("SELECT Error: ".mysql_error()); $result = mysql_query("SELECT * FROM table_name WHERE upper($field1) LIKE '%$find1%' AND upper($field2) LIKE '%$find2%' ") or die("SELECT Error: ".mysql_error()); $num_rows = mysql_num_rows($result); echo "There are $num_rows records:<br>"; echo '<center>'; echo "<table border='1' cellpadding='5' width='990'>"; // set table headers echo "<tr><th>Reference</th> <th>First Name</th> <th>Last Name</th> </tr>"; //get images and names in two arrays $name= $row["name"]; $surname= $row["surname"]; $achieve1 = $row["achieve1"]; $achieve2 = $row["achieve2"]; $achieve3 = $row["achieve3"]; $achieve4 = $row["achieve4"]; $achieve5 = $row["achieve5"]; $achieve6 = $row["achieve6"]; $achieve7 = $row["achieve7"]; $achieve8 = $row["achieve8"]; $assoc1 = $row["assoc1"]; $assoc2 = $row["assoc2"]; $assoc3 = $row["assoc3"]; $assoc4 = $row["assoc4"]; $assoc5 = $row["assoc5"]; $edu1sectype = $row["edu1sectype"]; $edu1secinst = $row["edu1secinst"]; $edu1secname = $row["edu1secname"]; $edu1secdate = $row["edu1secdate"]; $edu1secinsttyp = $row["edu1secinsttyp"]; $subject1 = $row["subject1"]; $subject2 = $row["subject2"]; $subject3 = $row["subject3"]; $subject4 = $row["subject4"]; $subject5 = $row["subject5"]; $subject6 = $row["subject6"]; $subject7 = $row["subject7"]; $subject8 = $row["subject8"]; $compsoft1name = $row["compsoft1name"]; $compsoft2name = $row["compsoft2name"]; $compsoft3name = $row["compsoft3name"]; $compsoft4name = $row["compsoft4name"]; $compsoft5name = $row["compsoft5name"]; $compsoft6name = $row["compsoft6name"]; $achievements = array('achieve1', 'achieve2', 'achieve3', 'achieve4', 'achieve5', 'achieve6', 'achieve7', 'achieve8'); $associations = array('assoc1', 'assoc2', 'assoc3', 'assoc4', 'assoc5'); $subjects = array('subject1', 'subject2', 'subject3', 'subject4', 'subject5', 'subject6', 'subject7', 'subject8' ); $compsoft = array('compsoft1name', 'compsoft2name', 'compsoft3name', 'compsoft4name', 'compsoft5name', 'compsoft6name'); while ($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td ALIGN=LEFT>" . $row['id'] . "</td>"; echo "<td ALIGN=LEFT>" . $row['name'] . "</td>"; echo "<td ALIGN=LEFT>" . $row['surname'] . "</td>"; echo "</tr>"; } echo "</table>"; //This counts the number or results - and if there wasn't any it gives them a little message explaining that $anymatches=mysql_num_rows($data); if ($anymatches == 0) { echo "Sorry, but we can not find an entry to match your query"; } } ?> </body> </html>Any assistance will be greatly appreciated as I have been working on this website for the past 4 months which has totalled over 150 pages and this is one of the last pages left to program and it's taken 6 days to get to this search page to this point. 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 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"); } ?> 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 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, first time poster.. I've looked the web over for a long time and can't figure this one out. - Below is basic code that successfully checks MySQL for a match and displays result. I was debugging and forced the "height" and "width" to be 24 and 36 to make sure that wasn't the problem. That's good.. - I'd like to give the user ability to select width and height from a form.. and have it do an onchange this.form.submit so the form can be changing as fields are altered (thus the onchange interaction) - In a normal coding environment I've done this numerous times with no "Page cannot be displayed" problems. It would simply change one select-option value at a time til they get down the form and click submit... but in WordPress I'm having trouble making even ONE single onchange work! - I've implemented the plugins they offer which allows you to "copy+paste" your php code directly into their wysiwyg editor. That works with basic tests like my first bullet point above. - I've copied and pasted the wordpress url (including the little ?page_id=123) into the form "action" url... that didn't work... tried forcing it into an <option value=""> tag.. didn't work. I'm just not sure. I've obviously put xx's in place of private info.. Why does this form give me Page Cannot Be Displayed in WordPress every time? It won't do anything no matter how simple.. using onchange.. Code.. $con = mysql_connect("xxxx.xxxxxxx.com","xxxxxx","xxxxx"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("xxxxxx", $con); $myprodwidth=24; $myprodheight=36; $result = mysql_query("SELECT * FROM product_sizes WHERE prodwidth='$myprodwidth' and prodheight='$myprodheight'"); while($row = mysql_fetch_array($result)) { echo $row['prodprice']; } mysql_close($con); <form method="post" action=""> <select name="myheight" onchange="this.form.submit();"> <option selected="selected" value="">select height</option> <option value="xxxxxxxxx.com/wordpress/?page_id=199&height=36">36</option> <option value="xxxxxxxxx.com/wordpress/?page_id=199&height=36">48</option> </select> In drive.php
public function insert($postBody, $optParams = array()) |