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

  • W3Schools
    • General
    • Suggestions
    • Critiques
  • HTML Forums
    • HTML/XHTML
    • CSS
  • Browser Scripting
    • JavaScript
    • VBScript
  • Server Scripting
    • Web Servers
    • Version Control
    • SQL
    • ASP
    • PHP
    • .NET
    • ColdFusion
    • Java/JSP/J2EE
    • CGI
  • XML Forums
    • XML
    • XSLT/XSL-FO
    • Schema
    • Web Services
  • Multimedia
    • Multimedia
    • FLASH

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


Languages

  1. Hi good people of w3, I'd been using the tutorials on this site a lot in an attempt to get the email enquiry form working for the website I've been putting together for the place I'm currently employed at. This isn't exactly my forte, I'm pretty decent when it comes to html but php is an animal I'm only just starting to become familiar with.I have an issue currently where particular parts of the form are required to be filled in, and I can successfully generate errors when this does not occur. However, the errors do not actually stop the email from being sent and hence we end up with incomplete enquiries on the other side when the form is not correctly filled in.If anyone could provide some advice as to a means to make the errors stop the email from being sent, that would be much appreciated. The relevant code is below. <?php// define variables and set to empty values$nameErr = $emailErr = $partErr = $phoneErr = "";$name = $email = $part = $comments = $model = $brand = $phone = $contact_method = $product = $breakdown = "";if ($_SERVER["REQUEST_METHOD"] == "POST") { if (empty($_POST["name"])) { $nameErr = "Name is required"; } else { $name = test_input($_POST["name"]); // check if name only contains letters and whitespace if (!preg_match("/^[a-zA-Z ]*$/",$name)) { $nameErr = "Only letters and white space allowed"; } } if (empty($_POST["email"])) { $emailErr = "Email is required"; } else { $email = test_input($_POST["email"]); // check if e-mail address is well-formed if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { $emailErr = "Invalid email format"; } } if (empty($_POST["phone"])) { $contact_methodErr = "Phone number is required"; } else { $phone = test_input($_POST["phone"]); } $contact_method = test_input($_POST["contact_method"]); $brand = test_input($_POST["brand"]); $product = test_input($_POST["product"]); $model = test_input($_POST["model"]); $breakdown = test_input($_POST["breakdown"]); if (empty($_POST["part"])) { $partErr = "Part number or description is required"; } else { $part = test_input($_POST["part"]); } $comments = test_input($_POST["comments"]); } function test_input($data) { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); return $data;}// Function to validate against any email injection attemptsfunction IsInjected($str){ $injections = array('(n+)', '(r+)', '(t+)', '(%0A+)', '(%0D+)', '(%08+)', '(%09+)' ); $inject = join('|', $injections); $inject = "/$inject/i"; if(preg_match($inject,$str)) { return true; } else { return false; }} //Validate firstif(IsInjected($customer_email)){ echo "Bad email value!"; exit;} $email_from = 'sales@speedyspares.com';//<== update the email address $email_subject = "Online Enquiry"; $email_body = '<html><body>'; $email_body .= '<table rules="all" style="border-color: #666;" cellpadding="10">'; $email_body .= "<tr style='background: #eee;'><td><strong>Name:</strong> </td><td>" . $name = $_POST["name"] . "</td></tr>"; $email_body .= "<tr><td><strong>Email:</strong> </td><td>" . $email = $_POST["email"] . "</td></tr>"; $email_body .= "<tr><td><strong>Phone:</strong> </td><td>" . $phone = $_POST["phone"] . "</td></tr>"; $email_body .= "<tr><td><strong>Preferred Method of Contact:</strong> </td><td>" . $contact_method = $_POST[ "contact_method"] . "</td></tr>"; $email_body .= "<tr><td><strong>Brand:</strong> </td><td>" . $brand = $_POST["brand"] . "</td></tr>"; $email_body .= "<tr><td><strong>Product:</strong> </td><td>" . $product = $_POST["product"] . "</td></tr>"; $email_body .= "<tr><td><strong>Model:</strong> </td><td>" . $model = $_POST["model"] . "</td></tr>"; $email_body .= "<tr><td><strong>Breakdown Required:</strong> </td><td>" . $breakdown = $_POST["breakdown"] . "</td></tr>"; $email_body .= "<tr><td><strong>Part:</strong> </td><td>" . $part = $_POST["part"] . "</td></tr>"; $email_body .= "<tr><td><strong>Comments:</strong> </td><td>" . $comments = $_POST["comments"] . "</td></tr>"; $email_body .= "</table>"; $email_body .= "</body></html>"; $to = "sales@speedyspares.com";//<== update the email address $headers = "From: $email_from rn"; $headers .= "Reply-To: $email rn"; $headers .= "MIME-Version: 1.0rn"; $headers .= "Content-Type: text/htmlrn"; //Send the email! mail($to,$email_subject,$email_body,$headers); //done. redirect to thank-you page. header('Location: thankyou.html'); ?><form method="post" name="enquiry-form" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>"> <h6><strong><span class="redasterisk">*</span></strong>denotes a required field</h6> <h6>Name:<span class="error">* <?php echo $nameErr;?></span><br> <input name="name" type="text" size="50"> <br> E-mail:<span class="error">* <?php echo $emailErr;?></span><br> <input name="email" type="text" size="50"> <br> Phone:<span class="error">* <?php echo $phoneErr;?></span><br> <input name="phone" type="text" size="50"> <br /> Preferred Contact Method:<br /> <input type="radio" name="contact" value="email" /> Email <input type="radio" name="contact" value="phone" /> Phone <br /> Brand:<br> <select name="brand"> <option value="Sony">SONY</option> <option value="Sharp">SHARP</option> <option value="Hills">HILLS</option> <option value="Other">OTHER</option> </select><br /> Product:<br> <select name="product"> <option value="TV">TV/PROJECTOR</option> <option value="VIDEO">HOME VIDEO/DVD/BLU-RAY</option> <option value="AUDIO">HOME AUDIO/THEATRE SYSTEM</option> <option value="CAMERA">DIGITAL STILL CAMERA</option> <option value="CAMCORDER">VIDEO CAMERA/CAMCORDER</option> <option value="VAIO">PERSONAL COMPUTER (VAIO)</option> <option value="EREADER">eBOOK READER</option> <option value="PAUDIO">PERSONAL AUDIO</option> <option value="CAUDIO">CAR AUDIO</option> <option value="FRIDGE">REFRIDGERATOR</option> <option value="MICROWAVE">MICROWAVE</option> <option value="OTHER">OTHER</option> </select><br /> Model :<br /><em>(eg. KDL-46HX800)</em><br> <input type="text" name="model" size="50"> <br /> <input type="checkbox" name="breakdown" value="Yes" /> Request Breakdown<br /> Part number/description:<span class="error">* <?php echo $partErr;?></span><br /><em>(e.g. UWA-BR100 Wi-fi Adaptor)</em><br /> <input type="text" name="part" size="50"> <br> Comments:<br> <textarea name="comments" cols="50" rows="5">Please supply any additional information that may assist with your enquiry. (color/size/location etc.)</textarea> <br /> (Please do not use this form for submission of credit card information)</h6> <h5> <input type="submit" name="submit" value="Submit"> <input type="reset" name="reset" value="Reset"> </h5> </form>
  2. I can't use the function of geolocation in my desktop. Browsers are Firefox and Google Chrome. OS is window xp. I click the button to get positon and also click "share position info" The result: Firefox alert "Unknown error acquiring position" Google Chrome alert "Javascript notice: User denied Geolocation" <!doctype html><html> <head> <meta charset="utf-8"> <title>Geolocation test</title> </head> <body> <p>Your latitude:<span id = "latitude">000</span></p> <p>Your longitude:<span id = "longitude">000</span></p> <p><button onClick="getPosition()">click for your position</button></p> <script> function getPosition(){ if(navigator.geolocation){ navigator.geolocation.getCurrentPosition(showPosition, errorMessage); } else{ alert("this browser does not support geolocation"); } } function showPosition(position){ document.getElementById("latitude").innerHTML = position.coords.latitude; document.getElementById("longitude").innerHTML = position.coords.longitude; } function errorMessage(error){ alert(error.message); } </script> </body></html> I am trying to solve the problem by searching Google. I got some information in the following link: https://bugzilla.mozilla.org/show_bug.cgi?id=822967 Some people said that desktop can't use geolocation. Is it right? Any solution?
  3. Hi W3Schoolers. I have downloaded Bootstrap 3.1 and after that, my glyphicons are not properly visible as below. They are shown 'x' square box instead of real images. I followed some advises from internet, and deleted Bootstrap, re-download it, also deleted glyphicon font files from library>fonts folder and re-installed it too. But it is still same. My laptop is Macbook air 2011, and OS is Mavericks 10.9.3 Please help me to find out solution. Thanks in advance. Jin
  4. westman

    site error

    hi all I have an error on my site and I don't know how to fix it or why it's there It happens every now and then when I am surfing my site. Google chrome give me this: No data received Unable to load the web page because the server sent no data. Error code: ERR_EMPTY_RESPONSE Any help?
  5. Hi, I have a mysqli_query that goes like this: $result = mysqli_query($db, "INSERT INTO device(`Identifier`, `IsAllowedToPost`)VALUES('ABC123', 0)") or die(error_log(mysqli_error($db), 3, "php_error.log")); It does not work and the logs either tells me "1", "0" or nothing depending on which method I try to log the error with. How can I get a better error message to log in my file? 1 or 0 means nothing to me. The current code gives me no error message at all in my file and the data does not get stored in the database.
  6. expensiveal

    Help PHP error

    Hii'am new in this forum yesterday i created an Affilatereferral program with PHP Fixthewindows.combut i'am getting an errorParse error: syntax error, unexpected '=', expecting ')' in /home/u479191455/public_html/common.php on line 9The code of common.phpcommon.phpin Dreamweaver CC i'am getting more errorsError Line : 9 , 10 , 11 , 12 , 13 , 14 , 15 , 17 ,24 , , 60 , 61,62,63,64,66 Please Help !
  7. Hello, i'm wondering how to install Apache2 with PHP inside. So far i've downloaded dozens of apache servers and php servers and always getting the the error below. LoadModule php5_module "c:/php/php5apache2.dll" not found (or something very similar) Does certain Apache server version require certain PHP version? I'm pointing out the correct directory and its still telling that its wrong folder. Last time i tried these files.httpd-2.0.65-win32-x86-no_ssl.msiphp-5.3.28-nts-Win32-VC9-x86.msi And received same results. Modified php.ini to point out the extensions folder, added these lines to httpd config file (To correct positions). LoadModule php5_module "c:/php/php5apache2.dll"AddType application/x-httpd-php .phpPHPIniDir "c:/php" I have to install Apache2 the hard way since Xampp has been buggy for me for a bit. Please reply with correct version links and other tutorials if there is.
  8. Hi all, what a great forum you've created. I keep reading and eventually I need your help. I'm running that site and the W3 Validator spits out some errors related to the brackets. As you see, I'm using a wordpress theme and I don't even see those brackets in my code. Now I'm wondering if you have any solutions to that which you can offer. Thanks and regards Chris
  9. Can anybody help me on this issue? It's very important to my site. Some (although not all) of my permalinks won't work. Some work perfectly and some are having variants of this "%20%E2%80%8E" added to the end of them, which obviously is giving me the 404 message. I've tried deactivating plug ins but had no difference and obviously as some work, it is unlikely to be that. I have also checked for hidden characters but cannot seem to find any. Can anybody think of a viable reason/solution for this error? Thanks
  10. Hi, Does anyone have any idea why the W3 validation service returns the error shown below on this comment line?/* Set the values in the <img> tag so the user can see a mini-sample of what was selected */Error:=====Line 219, Column 40: required attribute "src" not specified… /* Set the values in the <img> tag so the user can see a mini-sample …✉The attribute given above is required for an element that you've used, but you have omitted it. For instance, in most HTML and XHTML document types the "type" attribute is required on the "script" element and the "alt" attribute is required for the "img" element.Typical values for type are type="text/css" for <style> and type="text/javascript" for <script>.=====I've tried /* */ to enclose the comment and also //Thanks for your help.andynic
  11. Hi, I'm new to ASP and working from a dated book. The code in one example keeps giving me an error. Can anyone tell me what's wrong with the code? I'm using Dreamweaver to write the code, but running through the internet. The files are saved on the web server. I use crome because it tells me what's wrong. I'll post the code then post the error report. The code (and by the way, the txt file already exist.) <%option explicit %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR...ransitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>Guest Book</title></head><body><h1>Guest Book Response</h1><%=request.form("FirstName")%> <br /><%=request.form("LastName")%> <br />Gender:<%=request.form("Gender")%> <br />Age:<%=request.form("Age")%><br />Email:<%=request.form("email")%><br /><br /><%Dim filesys, peoplefileSet filesys = createobject("scripting.FileSystemObject")Set peoplefile=FileSys.OpenTextFile("Z:\vreid\gbpeople.txt",8,true)Peoplefile.writeline request.form("firstname")Peoplefile.writeline request.form("Lastname")Peoplefile.writeline request.form("Gender")Peoplefile.writeline request.form("age")Peoplefile.writeline request.form("email")Peoplefile.close%><h3> This information has been saved.</h3><a href="gblist.asp">See others who signed in.</a></body></html> The result: Guest Book Response Ginger, ReidGender:male, FemaleAge:32Email:greid@radford.edu Microsoft VBScript runtime error '800a004c'Path not found/gbproc.asp, line 19
  12. Hello, all! I want to create a sign-up page, then i make signup.html and signup.php ...The signup html goes well, but the signup php doesn't.. Please check what's wrong with my code... signup.html <!DOCTYPE html><html><head><title>Sign Up Now!</title><link rel="stylesheet" type="text/css" href="signup.css" /></head><body><h1>Sign up now and get the gifts!<h1><h3>Type down your identity !</h3><form method="post" action="signup.php"><fieldset><legend>Sign Up</legend><label for="fname">First Name:</label><input type="text" id="fname" name="fname" /> <label for="lname">Last Name:</label><input type="text" id="lname" name"lname" /> <label for="email">Email</label><input type="text" id="email" name="email" /> <label for="country">Country</label><input type="text" id="country" name="country" /> <label for="gender">Gender</label><input id="gender" name="gender" type="radio" value="male">Male<input id="gender" name="gender" type="radio" value="female">Female <label for="reason">Why do you want to join us ?</label><textarea id="reason" name="reason"></textarea> <input type="submit" value="Sign Up!" name="submit" /></fieldset></form></body></html> signup.php <!DOCTYPE html><html><head><title>Thanks for signing up!</title></head><body><h2>Wait till the admin validates your account</h2><?php$name = $_POST['fname'] . " " . $_POST['lname'];$email = $_POST['email'];$country = $_POST['country'];$gender = $_POST['gender'];$reason = $_POST['reason']; echo 'Thanks for signing up, ' . $name . '';echo 'Those datas you input will be emailed to admin' . '';echo 'Name : ' . $name . '';echo 'Email : ' . $email . '<br/>';echo 'Country : ' . $country . '';echo 'Gender : ' . $gender . '';echo 'I join this because ' . $reason;?> </body></html> When i fill in the form, then submit them.. Then the signup.php appears and the output is below Wait till the admin validates your account Notice: Undefined index: lname in C:xampphtdocsphpsignup.php on line 9Thanks for signing up, aaaaThose datas you input will be emailed to adminName : aaaaEmail : aaaa@aa.comCountry : aaaaGender : maleI join this because i like it Please fix this... P.S. I run it in localhost
  13. <script>int[][] num = new int[4][5];num[1][1]={0,1,2,3,4};alert(num[1][2]);</script> This give my an error " Uncaught SyntaxError: Unexpected token ] " (shown by chrome) #for the "int[][] num = new int[4][5];" line Please help.
  14. ok, just quick... im getting this when trying to login: Unknown column 'e5035533a816cac4c54012281f58543d' in 'where clause' and this is my takelogin.php file: /*==========RUN LOGIN PROCEDURE===============*/$uname = sqlesc($_POST['username']); /*Form Names...*/$pass = sqlesc($_POST['password']); /*Form Names...*/if(isset($pass)){$passhash = md_5($pass); /*Securing The Data...*/}$query = "SELECT * FROM users WHERE username = $uname AND passhash = $passhash AND enabled = 'yes' AND status = 'confirmed'";$query_result = mysql_query($query)or die(mysql_error());//Running query to the DB...if(mysql_num_rows($query_result) == 1)/*if the DB returns somfthing, then run...*/{$row = mysql_fetch_array($query_result);$_SESSION['uid'] = $row['u_id'];$_SESSION['username'] = $row['username'];$_SESSION['pass'] = $row['passhash'];$_SESSION['status'] = $row['status'];$_SESSION['enabled'] = $row['enabled'];$_SESSION['email'] = $row['email'];$_SESSION['ip'] = $row['ip'];$_SESSION['class'] = $row['class'];$_SESSION['time_offset'] = $row['time_offset'];$_SESSION['dst_in_use'] = $row['dst_in_use'];$_SESSION['auto_correct_dst'] = $row['auto_correct_dst'];header('Refresh: 3; url=index.php');//with time delay...}else/*Error messeage...*/{$HTMLOUT .= "<center>Error reading login-session coding base, or a wrong username/pass inserted...</center>";header('Refresh: 3; url=index.php');//with time delay...}/*==========RUN LOGIN PROCEDURE===============*/ any ideas? Oo...
  15. On my register page when i enter character to username field google chrome console will give me this error: Uncaught TypeError: Cannot read property 'name' of undefined Fix would be awesome
  16. hello...everyone. im getting this error whenever i start my system .on Desktop it will show this Error"call was canceled by the message filter.(Exception from HRESULT:0x80010002(RPC_E_CALL_CANCELED))"i donno what it is...please someone help me...im using Asus X54H ,Windows 7.. Thanku..!!
  17. hey guys, I'm trying to switch my mysql connections over to PDO but I'm having a hard time. I've read a section on it in the php book I'm reading, I watched the phpacademy,org tutorial on it, I've read the section on it here at w3schools and I can't get it working. I've also posted it on 2 other forums and no one has yet to figure out where the problem is and it's eaten up 2 days of my time as well. If I can't get it figured out today I'm seriously thinking of going back to using the old mysql functions because they worked right the first time and have never given me an ounce of trouble. It's just very frustrating that my registration/login system was working perfect and then I upgrade and nothing works and no one can figure it out. . . It says the error is on line 142, which is the fetchAll() function line. Thanks for any help you guys can offer! Here is the connection script <?php// Connects to Our Database$db_host = "localhost";$db_user = "root";$db_password = "";$db_database = "game_db";try{ $conn = new PDO ('mysql:host=localhost;dbname=game_db', $db_user, $db_password);$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);} catch (PDOException $e) { echo 'ERROR: ' . $e->getMessage();}?> And the query thats giving me the trouble $sql = "INSERT INTO `player_data` (`username`, `empire_name`, `ruler_name`, `founding_group`, `government`, `population`, `currency`, `p_currency`, `scrap`, `food`, `fuel`, `salvage_wpn`, `scrap_wpn`, `morale`, `initiative`, `influence`, `farms`, `housing`, `scrap_yards`, `barracks`, `taverns`, `scouts`, `militia`, `infantry`, `heavy_infantry`, `technicals`, `tanks`, `gate`, `tower`, `wall`, `tunnels`, `dogs`) VALUES (:user, :empire_name, :ruler_name, :founding_group, :government, 25, 1000, 100, 1000, 1000, 0, 0, 5, 10, 100, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)"; $query = $conn->prepare($sql); $query->bindValue(':user', $user, PDO::PARAM_STR); $query->bindValue(':empire_name', $empire_name, PDO::PARAM_STR); $query->bindValue(':ruler_name', $ruler_name, PDO::PARAM_STR); $query->bindValue(':founding_group', $founding_group, PDO::PARAM_STR); $query->bindValue(':government', $government, PDO::PARAM_STR); try { $query->execute(); } catch (Exception $e) { exit($e); } $row_count = $query->fetchAll(PDO::FETCH_ASSOC);
  18. When I try to run this update query in ms access 2007 I get an error box message that says "Data type mismatch in criteria expression". I know the problem is at the end around replace(property.[park city]," ","")=replace(locations2011.city," ",""). But I checked the data types for all the related columns, which is text, and they all match for both tables. If I put quotes around property.[park city] or remove the replace function from it, the query will run but obviously not how I want it to. I've tested this code with a smaller table and it works so what's the problem? UPDATE property, locations2011 SET property.county = locations2011.countyWHERE property.county Is Null And property.[park state]=locations2011.state And replace(property.[park city]," ","")=replace(locations2011.city," ",""); I know I can just remove all the spaces from the property table with ctrl+h replace all but I'd rather leave the data that's already there alone if possible.
  19. Can anyone tell me what is wrong with this file that keeps saying that this file is invalid. it seems certain jpg files are invalid while others are not. yet they all meet the guidelines establish. ERROR:Upload: americanrobinbird.jpgType: image/pjpegSize: 12.8095703125 KbStored in: /chroot/tmp/phpfryeow Invalid file Invalid file Upload.php file <?php$query = "SELECT * FROM {$dbprefix}pages ORDER BY hn ASC";$result = mysql_query($query) or die(mysql_error());while($row = mysql_fetch_array($result)){extract($row);$options .= "<option value='$pn'>$hn</option>";}$query = "SELECT * FROM {$dbprefix}leftnav ORDER BY name ASC";$result = mysql_query($query) or die(mysql_error());while($row = mysql_fetch_array($result)){extract($row);$folderoptions .= "<option value='$link'>$name</option>";}echo "<form action='upload_file.php' method='post' enctype='multipart/form-data'> <label for='file'>Filename:</label> <input type='file' name='file' id='file' /><br /> <label for='file'>File Belonges To:</label> <select name='powner' class='form' />$options</select><br /> <label for='file'>File Folder:</label> <select name='folder' class='form' />$folderoptions</select><br /> <input type='submit' name='submit' value='Submit' /> </form>";?> Upload php file: <?php include("config.php");include("themes/$theme/header.php");?><?php if ($_FILES["file"]["error"] > 0) { echo "Error: " . $_FILES["file"]["error"] . "<br />"; } else { echo "Upload: " . $_FILES["file"]["name"] . "<br />"; echo "Type: " . $_FILES["file"]["type"] . "<br />"; echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />"; echo "Stored in: " . $_FILES["file"]["tmp_name"]; } ?> <?php $allowedExts = array("jpg", "jpeg", "gif", "png"); $extension = end(explode(".", $_FILES["file"]["name"])); if ((($_FILES["file"]["type"] == "image/gif") || ($_FILES["file"]["type"] == "image/jpeg") || ($_FILES["file"]["type"] == "image/png") || ($_FILES["file"]["type"] == "image/jpg")) && ($_FILES["file"]["size"] < 20000) && in_array($extension, $allowedExts)) { if ($_FILES["file"]["error"] > 0) { echo "Error: " . $_FILES["file"]["error"] . "<br />"; } else { echo "Upload: " . $_FILES["file"]["name"] . "<br />"; echo "Type: " . $_FILES["file"]["type"] . "<br />"; echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />"; echo "Stored in: " . $_FILES["file"]["tmp_name"]; } } else { echo "Invalid file"; } ?> <?php $allowedExts = array("jpg", "jpeg", "gif", "png"); $extension = end(explode(".", $_FILES["file"]["name"])); if ((($_FILES["file"]["type"] == "image/gif") || ($_FILES["file"]["type"] == "image/jpeg") || ($_FILES["file"]["type"] == "image/png") || ($_FILES["file"]["type"] == "image/jpg")) && ($_FILES["file"]["size"] < 20000) && in_array($extension, $allowedExts)) { if ($_FILES["file"]["error"] > 0) { echo "Return Code: " . $_FILES["file"]["error"] . "<br />"; } else { echo "Upload: " . $_FILES["file"]["name"] . "<br />"; echo "Type: " . $_FILES["file"]["type"] . "<br />"; echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />"; echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />"; if (file_exists("$folder/" . $_FILES["file"]["name"])) { echo $_FILES["file"]["name"] . " already exists. "; } else { $name = $_FILES["file"]["name"]; $newname = "$folder/$name"; $query = "INSERT INTO {$dbprefix}pictures (plocation, powner) VALUES ('$newname', '$powner')"; $result = mysql_query($query) or die(mysql_error()); move_uploaded_file($_FILES["file"]["tmp_name"], "$folder/" . $_FILES["file"]["name"]); echo "Stored in: " . "$folder/" . $_FILES["file"]["name"]; echo "<script language=\"Javascript\">alert(\"Success!\");window.location.href = 'index.php?p=Upload';</script>"; } } } else { echo "Invalid file"; } ?> <?php include("themes/$theme/footer.php");?>
  20. Hello W3 People!. i have downloaded a picture upload class from here: verot.net.and working perfectly for my kind of coding in the schools. but i have never tried to make a (UPDATE) page of this kind of stuff where its deleting a picture and then uploading a new one dynamicly... and it does uploads the images correctly 100% and resizing them, and stuff like that... but it wont delete the older pictures, and update the Database Tables/Rows with the new image URL (witch are just the name of the the picture... im defining the path the diffrent places myself...) ideas?... here is my code [A LITTLE LONG...]: <?phpsession_start();ob_start();require_once("../db_conn.php");require_once("../login_checker_noroot.php");require_once("pic_mobel_uploader/class/class.upload.php");echo "<a href='index.php'>Tilbage Til Forsiden</a>"; if(!empty($_GET['m_id'])){$mid = $_GET['m_id'];$query = "SELECTdesigner.designer_navn,serie.serie_navn,produkter.design_aar,produkter.pris,produkter.vare_nr,produkter.information,produkter.produkt_navnFROMprodukter INNER JOIN serie ON produkter.FK_serie = serie.id INNER JOIN designer ON produkter.FK_designer = designer.d_id WHERE produkter.id = $mid";$result = mysql_query($query)or die(mysql_error());while($row = mysql_fetch_array($result,MYSQL_ASSOC)){ $p_navn = $row['produkt_navn']; $serie = $row['serie_navn']; $designer = $row['designer_navn']; $v_nr = $row['vare_nr']; $aar = $row['design_aar']; $pris = $row['pris']; $tekst = $row['information'];}//While Statement Ends... if(isset($_POST['Submit'])){$p_navnn = mysql_real_escape_string($_POST['p_navn']);$seriee = mysql_real_escape_string($_POST['serie']);$designerr = mysql_real_escape_string($_POST['designer']);$v_nrr = mysql_real_escape_string($_POST['v_nr']);$aarr = mysql_real_escape_string($_POST['aar']);$priss = mysql_real_escape_string($_POST['pris']);$tekstt = mysql_real_escape_string($_POST['tekst']);/*===================================*//*===================================*//*===================================*/if($_FILES['image'] >= 1)//bigger then one...{$pID = $_GET['m_id'];$queryImg = "SELECT * FROM image_url WHERE FK_produkt_id = " . $pID;$resultImg = mysql_query($queryImg)or die(mysql_error());while($rowImg = mysql_fetch_array($resultImg)){unlink('../../images/home_news_form/'.$rowImg['img_url']);unlink('../../images/mobel_details_big/'.$rowImg['img_url']);unlink('../../images/mobel_details_thumps_small/'.$rowImg['img_url']);unlink('../../images/mobel_liste_form/'.$rowImg['img_url']);}// as it is multiple uploads, we will parse the $_FILES array to reorganize it into $files$files = array();foreach ($_FILES['image'] as $k => $l){foreach ($l as $i => $v){ if(!array_key_exists($i, $files)) $files[$i] = array(); $files[$i][$k] = $v;}}// now we can loop through $files, and feed each element to the classforeach ($files as $file){if(!empty($_FILES['image']))//allways form name...{// we instanciate the class for each element of $file$handle = new Upload($file);//$file for the new (array images upload) to work...//$handle = new Upload($_FILES['image']); //OLD ONE... if ($handle->uploaded){ $handle->image_resize = true; $handle->image_ratio = true; $handle->image_x = 110; //Width in Pixels... $handle->image_y = 80; //Height in Pixels... $handle->Process('../../images/home_news_form/');}if ($handle->uploaded){ $handle->image_resize = true; $handle->image_ratio = true; $handle->image_x = 300; //Width in Pixels... $handle->image_y = 225; //Height in Pixels... $handle->Process('../../images/mobel_details_big/');}if ($handle->uploaded){ $handle->image_resize = true; $handle->image_ratio = true; $handle->image_x = 50; //Width in Pixels... $handle->image_y = 50; //Height in Pixels... $handle->Process('../../images/mobel_details_thumps_small/');}if ($handle->uploaded){ $handle->image_resize = true; $handle->image_ratio = true; $handle->image_x = 120; //Width in Pixels... $handle->image_y = 90; //Height in Pixels... $handle->Process('../../images/mobel_liste_form/');$image = $handle->file_dst_name;$produktID = $_GET['m_id']; mysql_query("UPDATE image_url SET img_url='$image', FK_produkt_id='$produktID' WHERE FK_produkt_id = ".$pID)or die(mysql_error());}}//end empty (FILES) statement...}//end foreach statement...}//if (FILES['image']) ends.../*===================================*//*===================================*//*===================================*/$query = "UPDATE produkter SET produkt_navn = '$p_navnn', FK_serie = '$seriee', FK_designer = '$designerr', vare_nr = '$v_nrr', design_aar = '$aarr', pris = '$priss', information = '$tekstt' WHERE id = $mid";mysql_query($query)or die(mysql_error());header("location:index.php");}//submit ends...}//IF !empty Statement Ends...else{ $p_navn = "NO ID SELECTED!..."; $serie = "NO ID SELECTED!..."; $designer = "NO ID SELECTED!..."; $v_nr = "NO ID SELECTED!..."; $aar = "NO ID SELECTED!..."; $pris = "NO ID SELECTED!..."; $tekst = "NO ID SELECTED!...";}?> <fieldset><legend>Redigering Af Vare</legend><form method="post" action="" enctype="multipart/form-data"><table border="1" align="center"><tr><td>Produkt Navn</td><td><input type="text" name="p_navn" value="<?php echo $p_navn; ?>" /></td></tr><tr><td>Serie</td><td><select name="serie"><option value="0">Vælg Serie</option><?php $m_query = "SELECT * FROM serie"; $m_result = mysql_query ($m_query)or die(mysql_error()); while ($m_row = mysql_fetch_array ($m_result)) { echo "<option value='" .$m_row['id']."'>" .$m_row['serie_navn']."</option>"; }?></select></td></tr><tr><td>Designer</td><td><select name="designer"><option value="0">Vælg Designer</option><?php$d_query = "SELECT * FROM designer";$d_result = mysql_query ($d_query)or die(mysql_error());while ($d_row = mysql_fetch_array ($d_result)){ echo "<option value='" .$d_row['d_id']."'>" .$d_row['designer_navn']."</option>";}?></select></td></tr><tr><td>Vare Nummer</td><td><input type="text" name="v_nr" value="<?php echo $v_nr; ?>" /></td></tr><tr><td>Aar</td><td><input type="text" name="aar" value="<?php echo $aar; ?>" /></td></tr><tr><td>Pris</td><td><input type="text" name="pris" value="<?php echo $pris; ?>" /></td></tr><?php$produkt_id = $_GET['m_id'];$query2 = "SELECT * FROM image_url WHERE FK_produkt_id = $produkt_id";$result2 = mysql_query($query2)or die(mysql_error());while($row2 = mysql_fetch_array($result2)){?><tr><td><?php echo "<img src='../../images/mobel_liste_form/".$row2['img_url']."'>"; ?></td><td><input type="file" name="image[]" id="image" /></td></tr><?php}?><tr><td>Teksten Her</td><td><textarea type="text" name="tekst" rows="10" cols="40" /><?php echo $tekst; ?></textarea></td></tr><tr><td> </td><td><input type="submit" name="Submit" value="Rediger Nu!" /></td></tr></table></form></fieldset> Hoping answers soon!... thanks (rootKID)... PS: any questions i need to answer, just ask... and ill try... [AND SORRY, BUT THE MOST OF THE CODING STYLE IS MADE IN DANISH, BUT I AM FROM DENMARK AFTERALL... I HAVE ALSO TRIED TO COMMENT OUT SOME (MOST OF IT) THE STUFF IN ENGLISH, HOPE IT HELPS...)
  21. Know what you are dealing with : ERROR AND EXCEPTION WHY THIS? When we debug our code that means we find errors and fix them. so it is wise to know about them whom we are dealing with GETTING STARTED:I cant see anything. where to find error?Errors will not always be visible to you. you will see what your php.ini setting is set to show. There is some directive which handle this behaviour.http://in2.php.net/m...en/ini.list.php find the directives here"display_error""error_reporting""error_log" (for error logging)You can set it in php.ini directly (Recomended for development server where you have access to them) or you can set it it using ini_set(). (extra reference)see the principle of changing configuration of php.inihttp://in2.php.net/m...nfiguration.phphttp://in2.php.net/m...anges.modes.php IF YOU USE INI_SET() , MAKE SURE IT IS THE TOP MOST CODE OF YOUR CODE OR INCLUDE/REQUIRE TREEError types: Syntactical error Runtime error Logical error Syntactical error: behaviour:This error means you are not following the grammer of PHP. you had mistaken somewhere that it can not parse your code. as it does not parse your code, this errors show you prior to running the code. so when you see thi error your code is not being run.How to fix them?It is the most easier to fix errors. it happends usually when we make typo or forgot to close braces or put expression terminator (";") etc. though when you see the error you have not to search your code randomly, php will tell you where to look for. the showed error line is not always the origin of the error.it could be prior to that line.READ THIShttp://in3.php.net/m...l/en/tokens.phphere you can see the list of avialable parser tokens. so next time when you will see them it won't be hard for you to fin the reason.prevention is better than cureYou can avoid much of parse error if you write well readable code followinga any code standard. likehttp://pear.php.net/...g-standards.phphttp://framework.zen...g-standard.html and using decent IDE(eg netbeans) or text editor(eg notepad++)http://netbeans.orghttp://notepad-plus-plus.org/Runtime Error:behaviour:Your code is gramatically right. your code has been parsed and it has turned into opcode. now it is time for running it. in runtime there may be such case arises when your program does not do what you expect. like you are trying to get an index of an array which does not exist, etchow to fix them?This is the part we spent mostly to debug our code. There is different level of error Fatal error Warning Notice Fatal error: as it is saying, it is fatal. when such error arised it exits the scripts. YOU MUST FIX IT Warning: It level is lower than Fatal error. but is origin of unexpected behaviour even can lead to fatal error. YOU MUST FIX ITNotice: Low level error. does not harm much. but can lead to higher level error. so YOU SHOULD FIX ITLogical error:behaviour:your code grammer is correct it runs well but it has problem with the logic. It is the hardes part of debugging codes. it is problem with your logic somewhere in the code, which prevent you to outputting expected result.How to fix?PHP cant help you with that. you have to do it yourself. you can do that by whitebox testing or blackbox testing. there is unit test for php which can also help you in that. How would i know so many different error?Runtime errors are documented in every function and method in. you will find that on the manual. when you see any error with particular function just go to manual and see what exception/error it can throw in certain situation. SOMETHING MODERATED:How to handle error?Error handling principle is not same in production and development enviourment. You would not like to show your code faults publicaly. would you? in that case you will log them somewhere instead of showing them.http://in.php.net/ma...n.error-log.phpthere is another option, recruite a error handler which will handle all the error as YOU WANT.http://php.net/set_error_handler I want to throw my own error. how to?there is trigger_error() which will let you throw your own error. remember user level error has also the three types, like Fatal error,warning,notice.check this for available error constant http://in.php.net/ma...c.constants.php TOWARD MORE ADVANCE:EXception?! what is it?Exception is a state where your code is not doing what you expected and you will have chance to terminate the program gracefully. as opposed to Errors which is state, unrecoverable(though there is conceptually difference in exception of php and other language like java. 'notice' and 'warning' is some kind of error but they are recoverable, program does not exist when they occurs)http://in2.php.net/m....exceptions.php Why we will use exception? why php API uses exception (eg PDO)?PHP already documented exception in their manual. there is no need to write down again. the most imporatnt features of exception is, it is CATCHABLE and it can BUBBLE UP. Most of newer API include exception for its robustness. It also needs less code to write. it is readable. People should use exception for error handling instead of old error handling methods (like $error=array()). is there any callback handler same as for error handler?yes there is.http://in.php.net/manual/en/function.set-exception-handler.php. it will also give you freedom to handle exception customacllyWe can catch exception. can we catch error?Yes we can. EVEN WE CAN CATCH THE FATAL ERROR. we can use error handler to catch error and then throw ErrorException. http://in.php.net/ma...orexception.php look at the example. errorException is also exception which extends exception class. they are intenteded for handling error with behaviour of exception. Why would i want to catch and throw errors?The answer is same, for the advantages of exception. a error may be thrown at bottom of the call stack. with exception or errorException you can catch in any level of call stack and show a gracefull error rather than terminating the application (incase of fatal error).Imagine a nonexistant file "require"ing breaking up your page in the middle. Notes:this is the summary of the story of error-exception for geting the concept. If there is any question and query about these, can post it in separate topic. if it needs to add something more or for any correction or improvements can PM me.the links are provided, have the depth information about what it is being posted here and posted links are meant to be followed. There is no any substitute for php manual itself.
  22. Tom

    Error Reporting

    Hi @ all, I've found an error at this forum. After I click the button "Alter Warning Level" I get an error report. I think, the easiest way is to hide the button if there is no warn status.
  23. <form name="form" action="enter.php" method="post"> First Name: <input type="text" name="first" /><br /> Last Name: <input type="text" name="last" /><br /> <input type="checkbox" name="c1" value="1" onclick="showSubmit()" /> <input type="checkbox" name="c1" value="1" onclick="showSubmit()" /> <input type="checkbox" name="c3" value="1" onclick="showSubmit()" /> <!-- SUBMIT BUTTON HERE --> </form> If I only check the 1st and the 3rd checkbox and press the submit button, but in my enter.php, I made it check print out each of the inputs like so: <?php echo $_POST["first"];echo $_POST["last"];echo $_POST["c1"]; echo $_POST["c2"]; echo $_POST["c3"];?> I will get a warning/error claiming that the c2 is undefined. Is there a built in function that checks if something is undefined ? That way I can use a if and else statement: if is it undefined, it will print something, and if it is checked (defined), make it print something else.
  24. ok... i tried to enter my localhost again today to edit a little more on my projects... then i get this error: (PICTURE ATTACHED...) What the heck is that?... i mean... this is the line its talking about: (?>) witch are my PHP ending tag... someone?... Attached my config file also...
  25. I'm relatively new to java, and I've been working on a gui. Now when I run my code instead of opening the gui window I get this message in my console: java.lang.NumberFormatException: empty Stringat sun.misc.FloatingDecimal.readJavaFormatString(Unknown Source)at java.lang.Double.parseDouble(Unknown Source)at package.PartA.initialize(PartA.java:215)at package.PartA.<init>(PartA.java:58)at package.PartA$1.run(PartA.java:45)at java.awt.event.InvocationEvent.dispatch(Unknown Source)at java.awt.EventQueue.dispatchEvent(Unknown Source)at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)at java.awt.EventDispatchThread.pumpEvents(Unknown Source)at java.awt.EventDispatchThread.pumpEvents(Unknown Source)at java.awt.EventDispatchThread.run(Unknown Source) Also I've narrowed it down to it being something to do with these 3 lines: dFP = Double.parseDouble(jTextFieldFP.getText());dFAP =Double.parseDouble(jTextFAP.getText());dFDD =Double.parseDouble(jTextFDD.getText()); Please see if it's something simple I've just overlooked! Thank you!
×
×
  • Create New...