Jump to content

Search the Community

Showing results for tags 'error'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

  1. Hi guys, I have the following code, which does work. The two problematic parts are pickup_location and drop_location. When I click Save the data is saved to the database and those two are saved to an array with multiple locations. However, opening err_log, I get the following for each one: Only variables should be passed by reference <?php // Include Header file which contains required credentials include_once('includes/header.php'); // Initialize variables $charterData = [ 'chtr_name' => '', 'chtr_description' => '', 'start_date' => '', 'end_date' => '', 'depot_start' => '', 'depot_finish' => '', 'driver' => '', 'fleet_number' => '', 'updated_by' => '', 'customer_name' => '', 'pickup_location' => [], 'drop_location' => [], 'pickup_time' => '', 'return_time' => '' ]; try { // Fetch current charter details $charterId = (int)$_GET['chtr_id']; // Assuming the charter ID is passed via the URL $fetchStmt = $conn->prepare("SELECT chtr_name, chtr_description, start_date, end_date, depot_start, depot_finish, driver, fleet_number, updated_by, customer_name, pickup_location, drop_location, pickup_time, return_time FROM charters WHERE chtr_id = ?"); $fetchStmt->bind_param("i", $charterId); $fetchStmt->execute(); // Initialize variables $pickupLocations = null; // or an appropriate default value $dropLocations = null; // or an appropriate default value $fetchStmt->bind_result( $charterData['chtr_name'], $charterData['chtr_description'], $charterData['start_date'], $charterData['end_date'], $charterData['depot_start'], $charterData['depot_finish'], $charterData['driver'], $charterData['fleet_number'], $charterData['updated_by'], $charterData['customer_name'], $pickupLocations, // Now properly initialized $dropLocations, // Now properly initialized $charterData['pickup_time'], $charterData['return_time'] ); $fetchStmt->fetch(); $fetchStmt->close(); // Convert pickup and drop locations from JSON to array $charterData['pickup_location'] = json_decode($pickupLocations, true) ?: []; $charterData['drop_location'] = json_decode($dropLocations, true) ?: []; // Check if the form is submitted if ($_SERVER["REQUEST_METHOD"] === "POST") { // User data foreach ($charterData as $key => $value) { if ($key === 'pickup_location' || $key === 'drop_location') { $charterData[$key] = array_filter(array_map('htmlspecialchars', $_POST[$key] ?? [])); } else { $charterData[$key] = htmlspecialchars(trim($_POST[$key] ?? '')); } } // Prepare an SQL statement for updating the charter $stmt = $conn->prepare("UPDATE charters SET chtr_name = ?, chtr_description = ?, start_date = ?, end_date = ?, depot_start = ?, depot_finish = ?, driver = ?, fleet_number = ?, updated_by = ?, customer_name = ?, pickup_location = ?, drop_location = ?, pickup_time = ?, return_time = ? WHERE chtr_id = ?"); // Bind parameters $stmt->bind_param("ssssssssssssssi", $charterData['chtr_name'], $charterData['chtr_description'], $charterData['start_date'], $charterData['end_date'], $charterData['depot_start'], $charterData['depot_finish'], $charterData['driver'], $charterData['fleet_number'], $charterData['updated_by'], $charterData['customer_name'], json_encode($charterData['pickup_location']), json_encode($charterData['drop_location']), $charterData['pickup_time'], $charterData['return_time'], $charterId ); // Execute the statement if (!$stmt->execute()) { throw new Exception("Error: " . $stmt->error); } echo '<script type="text/javascript"> Swal.fire({ icon: "success", title: "Great Job!", text: "Be proud! Charter has been updated successfully!", showConfirmButton: false, timer: 2500, footer: "Powered by NerfCMS" }); </script>'; } } catch (Exception $e) { $ErrMsg = $e->getMessage(); } ?> Can anyone please guide me in the right direction?
  2. Can someone please give me some guidance on how to deal with the following warning All directories and files in the path have full owner permissions and I've made myself the owner of them all (I'm on a linux system). I've also done the same with the /tmp folder. I can't even think of anything else to change and haven't found anything online that solves the issue. in case it's needed, the php is as follows: <?php require("assets/initializations.php"); if(isset($_POST['add_post']) && !empty($_FILES['post_image'])) { $filename = $_FILES['post_image']['name']; $file_tmp_name = $_FILES['post_image']['tmp_name']; $filesize = $_FILES['post_image']['size']; $file_ext = explode('.', $filename); $file_act_ext = strtolower(end($file_ext)); $allowed = array('jpeg', 'jpg', 'png', 'gif'); if(!in_array($file_act_ext, $allowed)) { header("Location: add_post.php?message=file_type_not_allowed"); } else { if($filesize > 10000000) { header("Location: add_post.php?message=file_too_large"); } else { $file_new_name = uniqid('', true) . "." . $file_act_ext; $dir = "../usernet/img/"; $target_file = $dir . basename($file_new_name); move_uploaded_file($file_tmp_name, $target_file); echo "<script>alert('Image uploaded successfully');</script>"; } } } I do get the javascript alert that's it's been successfully uploaded, but the image doesn't make it into the specified directory and I get the warnings at the top. I'm also, probably obviously from the path, using XAMPP server for development. TIA
  3. here is a code of sign in page I want to add a role access for the student, teacher, and admin I have table name student in the database and a column role see image attached for database include("dbconfig.php"); session_start(); if($_SERVER["REQUEST_METHOD"] == "POST") { // username and password sent from form $name = mysqli_real_escape_string($con,$_POST['name']); $password = mysqli_real_escape_string($con,$_POST['password']); $sql = "SELECT user_id FROM student WHERE name = '$name' and password = '$password'"; $result = mysqli_query($con,$sql); $row = mysqli_fetch_array($result,MYSQLI_ASSOC); // $active = $row['active']; $count = mysqli_num_rows($result); if($count == 1) { //session_register("name"); $_SESSION['login_user'] = $name; header("location: allstudents1.php"); }else { $error = "Your Login Name or Password is invalid"; } } ?>
  4. I'm not hoping to much that I can solve this thing, but maybe someone here who knows php well can help me. Screenshot: http://extrazoom.com/image-70122.html?heuln50x50 File: https://mega.nz/#!uYgWmRTL!5ZyabPKnYWjeG2sL_PXyfFaAKaJiv4zceQGrky7fmPk And yes, I replaced "preg_replace" with "preg_replace_callback" and I ended up here: Screenshot:: http://extrazoom.com/image-70124.html?heuln50x50 Thank you and sorry for my bad english, if it's bad .
  5. I am using this https://github.com/ircmaxell/password_compat I have no problem using it on a local server. But as soon as I test it on a live server, it gives me an error like this. Parse error: syntax error, unexpected '{' in /home/public_html/sub/snippets/password.php on line 19 The error is on the same line as the beginning of the code in that library. Why is this happening?
  6. Hi! I'm getting this PHP syntax error on line 87 of my file. ERROR: PHP Parse error: syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING) The function works fine, if I take the function out of that file and put it into a separate file, it works fine. function get_UserId($username){ include('config.php'); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } $sql = "SELECT id FROM users WHERE username='$username'"; $result = $conn->query($sql); $row = $result->fetch_assoc(); $id = $row['id']; $conn->close(); return $id; } Thanks
  7. I am building a website about Doctor who, and I want to post various quotes from a database, when I wrote the select-query, I got the following error: Quotes Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in /customers/e/a/c/doctorwhofans.be/httpd.www/test/Content/Quotes.php on line 106 (which is the one with the while expression). <?php //verbinding met de database require("./connect.php"); //select-query schrijven en uitvoeren $sql = " select * from QuotesTabel"; $result = mysql_query($sql); //alle records weergeven (terwijl er rijen gevonden worden. while ($row = mysql_fetch_assoc($result)) { //toon foto met info require("./ToonFoto.php"); } ?> Can someone help me please?
  8. I am using a simple image upload. http://www.w3schools.com/php/php_file_upload.asp It gives me 2 errors like this. Warning: move_uploaded_file(C:/xampp/htdocs/home/upload/images/grandpix 2.jpg): failed to open stream: No such file or directory in C:\xampp\htdocs\home\upload\post.php on line 174 Warning: move_uploaded_file(): Unable to move 'C:\xampp\tmp\phpF915.tmp' to 'C:/xampp/htdocs/home/upload/images/grandpix 2.jpg' in C:\xampp\htdocs\home\upload\post.php on line 174 This is my code. Post.php . I see that it's the "$target_dir" issue. How can I fix it? if(isset($_FILES['fileToUpload'])){ if(!empty($_FILES['fileToUpload']['name'])) { $target_dir = $_SERVER['DOCUMENT_ROOT'].'/home/upload/images/'; $target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]); $uploadOk = 1; $imageFileType = pathinfo($target_file,PATHINFO_EXTENSION); $check = getimagesize($_FILES["fileToUpload"]["tmp_name"]); if($check !== false) { $uploadOk = 1; } else { $errors[] = 'File is not an image.'; $uploadOk = 0; } // Check if file already exists if (file_exists($target_file)) { $errors[] = 'Sorry, file already exists.'; $uploadOk = 0; } // Check file size if ($_FILES["fileToUpload"]["size"] > 500000) { $errors[] = 'Sorry, your file is too large.'; $uploadOk = 0; } // Allow certain file formats if($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg" && $imageFileType != "gif" ) { $errors[] = 'Sorry, only JPG, JPEG, PNG & GIF files are allowed.'; $uploadOk = 0; } // Check if $uploadOk is set to 0 by an error if ($uploadOk == 0) { $errors[] = 'Sorry, your file was not uploaded.'; // if everything is ok, try to upload file } else { if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) { echo "The file ". basename( $_FILES["fileToUpload"]["name"]). " has been uploaded."; } else { $errors[] = 'Sorry, there was an error uploading your file.'; } } $insert_image = $db->prepare("INSERT INTO images(user_id, item_id, image_path, date_added) VALUES(:user_id, :item_id, :image_path, :date_added)"); $insert_image->bindParam(':user_id', $userid); $insert_image->bindParam(':item_id', $item_id); $insert_image->bindParam(':image_path', $target_file); $insert_image->bindParam(':date_added', $date_added); if(!$insert_image->execute()) { $errors[] = 'There was a problem uploading the image!'; } else { if(empty($errors)) { $db->commit(); $success = 'Your post has been saved.'; } else { $db->rollBack(); } } } else { $errors[] = 'An image is required!'; } }
  9. [Linux] PHP Notice: Undefined variable: connection in /var/www/html/popreport/functions.php on line 23 PHP Fatal error: Call to a member function query() on a non-object in /var/www/html/popreport/functions.php on line 23 The fuction output in the following program is called from another file called records records-board.php If you look at the program below you'll see that I did define $connection above line 23 in the file functions.php And for the second error I'm really not getting it because that same foreach loop was working fine with the exact same argument list when it was in the file records-board.php, but now that I've copied most of the code from records-board.php and placed it in functions.php all the sudden my program can't see the variable $connection and has a problem with my foreach loop on line 23. Again, both of those lines worked fine when they were in another file. functions.php <?php //session_start(); // open a DB connectiong $dbn = 'mysql:dbname=popcount;host=127.0.0.1'; $user = 'user'; $password = 'password'; try { $connection = new PDO($dbn, $user, $password); } catch (PDOException $e) { echo "Connection failed: " . $e->getMessage(); } $sql = "SELECT full_name, tdoc_number, race, facility FROM inmate_board WHERE type = 'COURT'"; function output() { foreach($connection->query($sql) as $row) { echo "<tr><td>$row[full_name]</td></tr>"; } } ?> records-board.php <? include 'functions.php'; php output(); ?> Any ideas?
  10. On my Joomla 2.5 / Virtuemart 3 website I get the following error - Warning: array_push() expects parameter 1 to be array, null given in /var/www/vhosts/pizzacaldo.co.uk/httpdocs/newjoomla/libraries/tcpdf/tcpdf.php on line 17047 Warning: array_push() expects parameter 1 to be array, null given in /var/www/vhosts/pizzacaldo.co.uk/httpdocs/newjoomla/libraries/tcpdf/tcpdf.php on line 17047 Warning: array_push() expects parameter 1 to be array, null given in /var/www/vhosts/pizzacaldo.co.uk/httpdocs/newjoomla/libraries/tcpdf/tcpdf.php on line 17047 Warning: array_push() expects parameter 1 to be array, null given in /var/www/vhosts/pizzacaldo.co.uk/httpdocs/newjoomla/libraries/tcpdf/tcpdf.php on line 17047 Warning: array_push() expects parameter 1 to be array, null given in /var/www/vhosts/pizzacaldo.co.uk/httpdocs/newjoomla/libraries/tcpdf/tcpdf.php on line 17047 I'm told on the Virtuemart forum it might be something to do with the PDF invoice generating (which I or my clients never use - only the admin order confirmation e-mail is used). Can someone please tell me how to fix this? Thanks.
  11. Guest

    PHP file upload problem

    I am trying to send a file through Rest Webservices using php and i was able to send the file through email but i'm having problems with the webservices, it only receives an empty file. <?php ini_set('display_errors', 1); error_reporting(E_ALL); if($_POST) { //check if its an ajax request, exit if not if(!isset($_SERVER['HTTP_X_REQUESTED_WITH']) AND strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) != 'xmlhttprequest') { $output = json_encode(array( //create JSON data 'type'=>'error', 'text' => 'Sorry Request must be Ajax POST' )); die($output); //exit script outputting json data } //Sanitize input data using PHP filter_var(). $user_name = filter_var($_POST["user_name"], FILTER_SANITIZE_STRING); $user_company = filter_var($_POST["user_company"], FILTER_SANITIZE_STRING); $user_email = filter_var($_POST["user_email"], FILTER_SANITIZE_EMAIL); $country_code = filter_var($_POST["country_code"], FILTER_SANITIZE_NUMBER_INT); $phone_number = filter_var($_POST["phone_number"], FILTER_SANITIZE_NUMBER_INT); $message = filter_var($_POST["msg"], FILTER_SANITIZE_STRING); $to_email = $user_email; //Recipient email, Replace with own email here $from_email = 'jveleztorres@wovenware.com'; //From email address (eg: no-reply@YOUR-DOMAIN.com) //additional php validation if(strlen($user_name)<4){ // If length is less than 4 it will output JSON error. $output = json_encode(array('type'=>'error', 'text' => 'Name is too short or empty!'.realpath(sys_get_temp_dir()."\\".basename($_FILES['file_attach']['tmp_name'])))); die($output); } if(strlen($user_company)<2){ // If length is less than 4 it will output JSON error. $output = json_encode(array('type'=>'error', 'text' => 'Company Name is too short or empty!')); die($output); } if(!filter_var($user_email, FILTER_VALIDATE_EMAIL)){ //email validation $output = json_encode(array('type'=>'error', 'text' => 'Please enter a valid email!')); die($output); } if(!filter_var($country_code, FILTER_VALIDATE_INT)){ //check for valid numbers in country code field $output = json_encode(array('type'=>'error', 'text' => 'Enter only digits in country code')); die($output); } if(!filter_var($phone_number, FILTER_SANITIZE_NUMBER_FLOAT)){ //check for valid numbers in phone number field $output = json_encode(array('type'=>'error', 'text' => 'Enter only digits in phone number')); die($output); } if(strlen($phone_number) != 7){ // Phone number can contain 4 characters $output = json_encode(array('type'=>'error', 'text' => 'Must only contain 7 numbers without including country code')); die($output); } if(strlen($message)<3){ //check emtpy message $output = json_encode(array('type'=>'error', 'text' => 'Too short message! Please enter something.')); die($output); } if(isset($_FILES['file_attach'])) //check uploaded file { //get file details we need $file_tmp_name = $_FILES['file_attach']['tmp_name']; $file_name = $_FILES['file_attach']['name']; $file_size = $_FILES['file_attach']['size']; $file_type = $_FILES['file_attach']['type']; $file_error = $_FILES['file_attach']['error']; //exit script and output error if we encounter any if($file_error>0) { $mymsg = array( 1=>"The uploaded file exceeds the upload_max_filesize directive in php.ini", 2=>"The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form", 3=>"The uploaded file was only partially uploaded", 4=>"No file was uploaded", 6=>"Missing a temporary folder" ); $output = json_encode(array('type'=>'error', 'text' => $mymsg[$file_error])); die($output); } } //read from the uploaded file & base64_encode content for the mail $convertIt = $_FILES['file_attach']['type']; $whatIWant1 = substr($convertIt, strpos($convertIt, "/") + 1); if($whatIWant1 === "octet-stream"){ $whatIWant = "zip"; } else{ $whatIWant = $whatIWant1; } //email body with attachment $message_body = "Message: ".$message."<br/>"."Contractor".$user_name."<br/>"."Company:".$user_company."<br/>"."Email : ".$user_email."<br/>"."Phone Number : (".$country_code.") ". $phone_number."<br/>"."Access Bonita to initiate Invoice Approval process" ; $handle = $_FILES["file_attach"]["name"]; $uploadfile1 = "C:/Users/hrivera/Documents/".basename($_FILES['file_attach']['name']); $handle =fopen($uploadfile1,"r"); $uploadfile = tempnam(sys_get_temp_dir(), sha1($_FILES['file_attach']['name'])); if (move_uploaded_file($_FILES['file_attach']['tmp_name'], $uploadfile)) { require 'PHPMailerAutoload.php'; $mail = new PHPMailer; $mail->SMTPDebug = 3; // Enable verbose debug output $mail->isSMTP(); // Set mailer to use SMTP $mail->Host = 'smtp.gmail.com'; // Specify main and backup SMTP servers $mail->SMTPAuth = true; // Enable SMTP authentication $mail->Username = ''; // SMTP username $mail->Password = ''; // SMTP password $mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted $mail->Port = 587; // TCP port to connect to $mail->From = ''; $mail->addAddress(''); $mail->addAttachment($uploadfile, $user_company.' Invoice.'.$whatIWant); // Add attachments $mail->isHTML(true); // Set email format to HTML $mail->Subject = $user_company.' Invoice Approval Requested'; $mail->Body = $message_body; $mail->AltBody = ', Thank you and have a nice day'; if(!$mail->send()) { echo 'Message could not be sent.'; echo 'Mailer Error: ' . $mail->ErrorInfo; } else { echo 'Message has been sent'; } } //Login to bonitasoft by using REST API function httpRequest($host, $port, $method, $path, $params) { $paramStr = ""; if ($method == "GET" || $method == "POST" ) { foreach ($params as $name => $val) { $paramStr .= $name . "="; $paramStr .= $val; $paramStr .= "&"; } } // Assign defaults to $method and $port, if needed if (empty($method)) { $method = "GET"; } $method = strtoupper($method); if (empty($port)) { $port = 8081; // Default HTTP port } // Create the connection $sock = fsockopen($host, $port); if (!$sock) { echo "Error! Couldn't open the file."; } else { if ($method == "GET") { $path .= "?" . $data; } //Necessary header fputs($sock, "$method $path HTTP/1.1\r\n"); fputs($sock, "Host: $host\r\n"); fputs($sock, "Content-type: application/x-www-form-urlencoded\r\n"); if ($method == "PUT") { fputs($sock, "Content-length: " . strlen($params) . "\r\n"); }elseif ($method == "POST") { fputs($sock, "Content-length: " . strlen($paramStr) . "\r\n"); } fputs($sock, "Connection: close\r\n\r\n"); if ($method == "PUT") { fputs($sock, $params); } elseif ($method == "POST") { fputs($sock, $paramStr); } // Buffer the result $result = ""; do { $temp = fgets($sock,1024); $result .= $temp; }while($temp !=""); fclose($sock); return $result; } } //Call to Function that logs into bonitasoft $resp = httpRequest("localhost", 8081, "POST", "/bonita/loginservice", array("username" => "walter.bates", "password" => "bpm")); $string = $resp; echo $resp; //Gets JSESSIONID preg_match("/Set-Cookie: (.*?) Path/",$string, $display); //Process to Start Case with variables $data = array("processDefinitionId"=>"5623733440372144264", "variables" => array(array("name" => "contractorComment", "value" => "$message"),array("name" => "contractorName", "value" => "$user_name"),array("name" => "contractorCompanyName", "value" => "$user_company"),array("name" => "contractorEmail", "value" => "$user_email"),array("name" => "contractorPhone", "value" => "("."$country_code".") "."$phone_number"))); $options = array( "http" => array( "method" => "POST", "header"=> "POST /bonita/API/bpm/case/ HTTP/1.1\r\n". "Host: localhost\r\n". "Cookie: ". $display[1]."\r\n". "Content-Type: application/json\r\n" . "Accept: application/json\r\n". "Cache-Control: no-cache\r\n". "Pragma: no-cache\r\n". "Connection: close\r\n\r\n", "content" => json_encode($data) ) ); $url = "http://localhost:8081/bonita/API/bpm/case/"; $context = stream_context_create( $options ); $result = file_get_contents( $url, false, $context ); $response = json_decode($result); echo print_r($response); preg_match('/"rootCaseId":"(.*?)",/',$result, $case_id); //Process to Attach Document to case //problem lies here $data1 = array("caseId"=> "$case_id[1]","file"=>realpath(sys_get_temp_dir()."\\".basename(sha1($_FILES['file_attach']['name']))),"name"=> "doc_Invoice", "fileName"=>"Invoice.pdf","description" => "Invoice"); echo json_encode($data1); switch (json_last_error()) { case JSON_ERROR_NONE: echo ' - No errors'; break; case JSON_ERROR_DEPTH: echo ' - Maximum stack depth exceeded'; break; case JSON_ERROR_STATE_MISMATCH: echo ' - Underflow or the modes mismatch'; break; case JSON_ERROR_CTRL_CHAR: echo ' - Unexpected control character found'; break; case JSON_ERROR_SYNTAX: echo ' - Syntax error, malformed JSON'; break; case JSON_ERROR_UTF8: echo ' - Malformed UTF-8 characters, possibly incorrectly encoded'; break; default: echo ' - Unknown error'; break; } $options1 = array( "http" => array( "method" => "POST", "header"=> "POST /bonita/API/bpm/case/ HTTP/1.1\r\n". "Host: localhost\r\n". "Cookie: ". $display[1]."\r\n". "Content-Type: application/json\r\n" . "Accept: application/json\r\n". "Cache-Control: no-cache\r\n". "Pragma: no-cache\r\n". "Connection: close\r\n\r\n", "content" => json_encode($data1) ) ); $url1 = "http://localhost:8081/bonita/API/bpm/caseDocument"; $context1 = stream_context_create($options1); $result1 = file_get_contents($url1, false, $context1); $response1 = json_decode($result1) ; echo print_r($response1); } ?>
  12. Hello everyone! I'm having issues with a delete button on a table row, im getting this error: Catchable fatal error: Object of class mysqli could not be converted to string in C:\xampp\htdocs\consultas\newdatapull.php on line 19 I'm not sure whats going on, here's my code: <?php include('header.php'); $servername = "localhost"; $username = "un"; $password = "admin"; $dbname = "emelyconsultas"; // Create connection $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); }; if (isset($_POST['delete'])) { $deleteQuery = "DELETE FROM hoteles WHERE id='$_POST[delete]'"; mysqli_query("$conn, $deleteQuery, "); }; $sql = "SELECT id, Full_Name, Email_Address, Telephone_Number, pais, ciudad, nombre_hotel, fecha_in, Fecha_out, adultos, ninos, mensaje FROM hoteles"; $result = $conn->query($sql); if ($result->num_rows > 0) { echo "<div class='container-fluid'> <div class='col-md-12'> <div id='datatable'class='table-responsive well'> <h1 class='text-center'>Entradas</h1> <table id='table' class='table'> <tr> <th>ID</th> <th>Nombre</th> <th>Correo Electronico</th> <th>Numero Telefonico</th> <th>Pais Destinado</th> <th>Ciudad Destinada</th> <th>Hotel</th> <th>Check In</th> <th>Check Out</th> <th>Adultos</th> <th>Niños</th> <th>Mensaje</th> </tr>"; // output data of each row while($row = $result->fetch_assoc()) { echo "<form action=newdatapull.php method=post>"; echo "<tr>"; echo "<td>" .$row['id'] . " </td>"; echo "<td>" .$row['Full_Name'] . " </td>"; echo "<td>" .$row['Email_Address'] . " </td>"; echo "<td>" .$row['Telephone_Number'] . " </td>"; echo "<td>" .$row['pais'] . " </td>"; echo "<td>" .$row['ciudad'] . " </td>"; echo "<td>" .$row['nombre_hotel'] . " </td>"; echo "<td>" .$row['fecha_in'] . " </td>"; echo "<td>" .$row['Fecha_out'] . " </td>"; echo "<td>" .$row['adultos'] . " </td>"; echo "<td>" .$row['ninos'] . " </td>"; echo "<td>" .$row['mensaje'] . " </td>"; echo "<td>" .$row['id'] . " </td>"; echo "<td>" ."<input class=input-group type=submit name=delete value=Borrar>" . "</td>"; "</form>"; echo "</tr></table></div></div></div>"; } } else { echo "0 results"; } $conn->close(); include('footer.php'); ?> thanks in advance to anyone that can help, Error comes up once I click the Delete button on the row...
  13. Not sure what is going on I tried everything (well, that I could think of) . . . any ideas are welcome (hopefully new ones - getting frustrated :/) if ($mysqli->prepare("INSERT INTO solcontest_entries (title, image,content, user, contest) VALUES ($title, $image, $content, $userid, $contest")) { $stmt2 = $mysqli->prepare("INSERT INTO `solcontest_entries` (title, image, content, user, contest) VALUES (?, ?, ?, ?, ?)"); $stmt2->bind_param('sssss', $title, $image, $content, $userid, $contest); $stmt2->execute(); $stmt2->store_result(); $stmt2->fetch(); $stmt2->close(); } else { die(mysqli_error($mysqli)); } Error I get from die mysqli_error: "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 ' of the site's lead ad, user_61609201, contest_1' at line 1" I have also tried $mysqli->query no change occured. I added the "if else die" statement because it was giving no errors, but not adding it to the database. It gives the error where $content is supposed to be inserted. Various combos and singles I tried for the variable: //$content = cleansafely($_POST['content']); //$content = mysqli_real_escape_string ($mysqli, $_POST['content']); //$content = cleansafely($content); $content = $_POST['content']; If any more information is needed please let me know.
  14. Hello, I've been working on rather simple comment system and when I try and grab all the comments that are "connected" to a post, I receive the Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42000] error. The full 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 '-5, 5' at line 1' in C:\xampp\htdocs\post\index.php:90 Stack trace: #0 C:\xampp\htdocs\post\index.php(90): PDO->query('SELECT * FROM c...') #1 {main} thrown inC:\xampp\htdocs\post\index.php on line 90 My code: $start = 0; $limit = 10; if(isset($_GET['p'])) { $id = $_GET['p']; } else { redirect("/"); } $start = ($id - 1) * $limit; $query = $database->query("SELECT * FROM comments WHERE post_id = '$id' ORDER BY date DESC LIMIT $start, $limit"); while($row = $query->fetch()) { $author = $row['author']; echo $author; } I honestly don't understand why this isn't working. I've used the exact same syntax for my post section on my website. If anything else is needed, just let me know. Thanks for the help!
  15. Keep getting these two errors when trying to UPDATE a field called "type" to 'banana' based on the fuitid. Why is this happening? Undefined index: fruitid in update.php 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 '' at line 1 <form method="POST" action="update.php"> <select> <option value="">Select</option> <?php $sql = "SELECT fruitid, datefrom, dateto FROM fruits"; $sqlresult = $link->query($sql); $sqllist = array(); while($row = mysqli_fetch_array($sqlresult)) { echo "<option>".$row['datefrom']." - ".$row['dateto']."</option>"; } ?> </select> <input type="hidden" value="<?php echo $fruitid;?>" name="fruitid"/> <input type="submit" value="Submit" name="submit"/> </form> <?php if(isset($_POST['submit'])) { $fruitid= mysqli_real_escape_string($link,$_POST['fruitid']); $sql = "UPDATE `fruits` SET `type`='banana' WHERE fruitid = $fruitid"; if (mysqli_query($link, $sql)) { echo "updated"; } else { echo "problem: " . mysqli_error($link); } } ?>
  16. So while editing my .HTACCESS file I added the proper lines to redirect users that encounter errors like 404 and 500. It works like a charm if I tell it to display a specific message. However if I tell the file to redirect users to a custom error page it fails. When testing out my 404 redirect I get this: Not Found The requested URL /143/test.php was not found on this server. Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request. Apache/2.4.9 (Win64) PHP/5.5.12 Server at localhost Port 80 As you can see it is stating that my ErrorDocument is not found BUT if I type my ErrorDocument URL in I can go to it myself. My .HTACCESS file looks like this: ErrorDocument 400 /error.php ErrorDocument 401 /error.php ErrorDocument 403 /error.php ErrorDocument 404 /error.php ErrorDocument 500 /error.php ErrorDocument 502 /error.php ErrorDocument 504 /error.php # supress php errors php_flag display_startup_errors off php_flag display_errors off php_flag html_errors off # enable PHP error logging php_flag log_errors on php_value error_log PHP_errors.log NOTE: I am using localhost (WAMP). Thanks.
  17. I have a pdo prepared statement that fetches records from mysql database. The records show up on the page. However if there are no records on a page, I get this error message. "QLSTATE[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 '-10' at line 4" Here is my statement $getCategoryId = $_GET['id']; $limit = 10; $offset = ($page - 1) * $limit; $statement = $db->prepare("SELECT records.*, categories.* FROM records LEFT JOIN categories ON records.category_id = categories.category_id WHERE records.category_id = :category_id ORDER BY record_id DESC LIMIT {$limit} OFFSET ".$offset); $statement->bindParam('category_id', $getCategoryId); $statement->execute(); $results = $statement->fetchAll(PDO::FETCH_ASSOC); If I remove try and catch block, it'll tell me exactly which line is giving the issue. So from the above code, the error has to do with "$statement->execute();". This is where the error occurs. As far as I know, the above pdo statement is correct. Can you tell me if something is wrong with it?
  18. Hello, i just install LAMP server. wrote simple code <?php #error_reporting(E_ALL); #printf "hello"; print "print_keyword."; ?> but in browser, it does not show me an error. i m using linux envionment. plz help. any help would be appriciable.
  19. We are not getting the error message, that should match with the error_code We sending the code and the object contains the error/success message to show!!! This seems to almost works. It is part of Jquery Validations, once the field or submit button is clicked. It looks for error on field. then Enter the Ajax Funciton which is to parse the error code and the out put the error message which is coming from json object. The code is not returning the error message, on line (alert(data)) Produces [object,object] not actual data string. The error message does not return. Please help, is there something work with our ajax request //*new style for error Messages*/ //var jsonErrors = frontEndErrorCodes; //JC wrote. //MG added. To retrieve Front-end error codes as well as //Backend Error Codes function _getErrorMessage(errorCode, message){ var errorData = JSON.stringify({error_code: errorCode, message: message}); var dataString = $.parseJSON(errorData); $.ajax({ url: './retrieveErrorMessage.json', type: 'POST', data: dataString, dataType: "json", contentType: 'application/json', mimeType: 'application/json', success: function(data) { //data = $.parseJSON(data); alert(data); $('.error.message').contents().find('h4').text(data.message); // if(!vanillaeGift.notify.called) { // $('.error.message').contents().find('h4').text(error.text()); // vanillaeGift.notify.showNotification(".error"); // } //Bolt Notification Called and Enabled here if(BoltNotify == true){ var spanerrorgen = $('.error.message').contents().find('h4').html(data.message); VanillaReload.notify.showNotification(".error"); }else if(BoltNotify == true && multipleNotice ==true ){ var spanerrorgen = $('.error.message').contents().find('h4').html(data.message); VanillaReload.notify.showNotification(".error").append(spanerrorgen); }else{ var spanerrorgen = $("<span/>").css("color","#D00").hide().addClass("error").html(data.message); $fieldref.parent().append(spanerrorgen) spanerrorgen.show("fast"); } }, error: function(data) { //data = $.parseJSON(data); alert(data); $('.error.message').contents().find('h4').text(data.message); // if(!vanillaeGift.notify.called) { // $('.error.message').contents().find('h4').text(error.text()); // vanillaeGift.notify.showNotification(".error"); // } //Bolt Notification Called and Enabled here if(BoltNotify == true){ var spanerrorgen = $('.error.message').contents().find('h4').html(data.message); VanillaReload.notify.showNotification(".error"); }else if(BoltNotify == true && multipleNotice == true ){ var spanerrorgen = $('.error.message').contents().find('h4').html(data.message); VanillaReload.notify.showNotification(".error").append(spanerrorgen); }else{ var spanerrorgen = $("<span/>").css("color","#D00").hide().addClass("error").html(data.message); $fieldref.parent().append(spanerrorgen) spanerrorgen.show("fast"); } }, fail: function(jqXHR, textStatus) { alert(data); if(textStatus == "parsererror"){ return "We're Sorry a system error occured"; } } }); }
  20. Hi, I'm Chris, first time here, I usually post on stackoverflow but I think that this is a little bit more complex than usual. I believe I really need a PHP expert to solve this issue. We have an application which is crawling the web. There's 2 main PHP scripts that are doing the work, using using proc_open, and exec() and running over a circular reference. Both scripts that compose the main structure are saving all and every single error on a custom error log, defined this way: //error_log @ini_set('error_reporting', -1); @ini_set('log_errors','On'); @ini_set('display_errors','On'); @ini_set('error_log','/var/www/vhosts/xxx/xxx/resonance/such_a_mess'); The problem is simple, after running for some hours or days, the application stops crawling. And there's no error information at all on the error_logs that could explain the problem or the reason why it stopped. I've been trying to get more details using Newrelic and XHProf, no luck.- There's no HTTP server involved on the execution of the scripts as they are being executed like I mentioned, using exec() and proc_open: exec("sh -c \"$cmd | logger\" > /dev/null &"); It has been around 3 months on the same situation... and to be honest the only thing I want at this point is to see a fatal error on the logs, to understand what's going on...
  21. Hey guys, So I making a basic website form to do CRUD operations on a database, and all of my components work, but I keep getting 500 - Internal server error on my index.php Heres my code: <?php require_once('config.php'); require_once('menu.php'); echo '<h1>View All Alien Interactions</h1>'; /* Start the table with the fields we want to display Remember $fields is now in config.php */ echo '<table> <tr>'; foreach($fields AS $label){ // th is a table header; the column's title or label. echo "<th>{$label}</th>"; } //Add the edit and delete columns at the end of the table echo '<th>Edit</th><th>Delete</th>'; echo '</tr>'; /* Select the fields we want, from all the rows The first line takes the array keys from our $fields array and implodes them, using backticks and commas. The end result will look like `first_name`, `last_name`, `phone_number`... The next line creates a SELECT query using that string. */ $fields_str = '`contact_id`, `'.implode(array_keys($fields), '`, `').'`'; $sql = "SELECT {$fields_str} FROM `aliens_abduction`"; foreach($dbh->query($sql) as $row) { echo '<tr>'; // Loop through the fields again to display them for this row. // Note: The tutorial originally contained an error here, this has been updated. foreach($fields AS $field=>$value){ // if the field is blank, we want to empty a blank space, otherwise the HTML won't work properly echo '<td>'.(isset($row[$field]) && strlen($row[$field]) ? $row[$field] : '&nbsp'.'</td>'); } echo '</tr>'; echo '<td><a href="edit.php?contact_id='.$row['contact_id'].'">Edit</a></td>'; echo '<td><a href="delete.php?contact_id='.$row['contact_id'].'">Delete</a></td>'; echo '</tr>'; echo '</table>'; ?> and heres my config.php code (idk if this is the root of the problem, i dummied out my credentials): <?php //Connect to the database $dbh = new PDO('mysql:host=xxxxxxxxx;dbname=db_demo', 'xxxxx', 'xxxxx'); //Set the default fetch mode to be an associative array. $dbh->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC); //Define the fields for our CRUD application $fields = array( 'first_name' => 'First Name', 'last_name' => 'Last Name', 'when_it_happened' => 'When it happened', 'how_many' => 'How many', 'alien_description' => 'Alien description', 'what_they_did' => 'What they did', 'fang_spotted' => 'Fang spotted', 'email' => 'Email' ); ?>
  22. why this simple code only works on chrome?? function mostrarOcultar(obj) { document.getElementById('seguro').style.visibility = (obj.checked) ? 'hidden' : 'visible'; } this the php: <table width="100%" border="1" id="seguro" style="visibility:visible"> <tr> <td bgcolor="#B4ED89" class="Estilo3"><?php echo "Cantidad Asegurada Bs" ?></td> <td width="47%"><input name="asegu" type="text" id="asegu" size="39" onkeypress="return NumCheck(event,this)" onpaste="return false"/></td> <tr> </table> only work on chrome and perfectly
  23. Hello, First of thank you for taking your time reading this, I have a question about what is wrong with my webserver. I made a website using PHP on my local WAMP server. I uploaded it to my webserver this morning and as it turns out something like <?php echo '<p>Hello World</p>'; ?> gets compiled to Hello World '; ?> I honestly have no idea what I have done wrong and I cant seem to find this anywhere... Hope to hear for someone soon Trevi
  24. Why does php show undefined variable? I researched and found out that if the variables aren't set then they will likely show undefined variable. However, I used the isset function to check if the variable is undefined and if it is then set it to $varaible ="" . That didn't work and then later i tried $variable = NULL. What should I do Can you please see the code and tell me what shall i do. Thanks a million <?php require_once("includes/connection.php")?> <?php require_once("includes/function.php") ?> <?php require_once("includes/header.php") ?> <?php if(isset($_GET['subj'])){ $sel_subj = NULL; $sel_subj = $_GET['subj']; } elseif (isset($_GET['page'])){ $sel_page = NULL; $sel_page = $_GET['page'] ; } else { $sel_subj= NULL; $sel_page =NULL; } ?> <table id = "structure" > <tr> <td id = "navigation" > <ul class= "subjects" > <?php $subject_set = get_all_subjects(); while ($subject = mysql_fetch_array($subject_set)){ // <a href = "content.php?subj=1" > if ($sel_subj == $subject["id"]){ echo "<li class = \"selected\" "; }else{ echo "<li> "; } "<a href = \"content.php?subj=" . urlencode($subject["id"]) . "\">" . $subject["menu_name"]. "</a></li>" ; $page_set = get_pages_for_subjects( $subject["id"] ) ; echo " <ul class = \"pages\"> "; while ($page = mysql_fetch_array($page_set)){ echo "<li><a href = \"content.php?page=" . urlencode($page["id"]) . "\">" . $page["menu_name"] . "</a></li>" ; } echo "</ul>" ; } ?> </ul> </td> <td id= "page" > <h1> Main Area To Get Your Information </h1> <?php echo $sel_subj ; ?> <br/> <?php echo $sel_page ; ?> <br/> </td> </tr> </table> <?php include ("includes/footer.php") ?> The variable im refering to is $sel_subj and $sel_page at the top of the code. Here is an attachment of the error
  25. Am using VIDSPLANET for my wordpress website. when I'm trying to add a video on the plugin, error i'm getting is can anybody help me? please.
×
×
  • Create New...

Important Information

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