Jump to content

Search the Community

Showing results for tags 'errors'.



More search options

  • 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 (Dreamweaver, Zend, 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

Found 10 results

  1. Hi all ! Here is a small piece of code that I wrote to Select from a DB:- $query = "SELECT Id, User, Pass, FROM $table WHERE User = ?"; $stmt = $con->prepare($query); $stmt->bind_param('s',$user); $stmt->execute(); $stmt->bind_result($db_id,$db_user,$db_pw); $stmt->fetch(); ... Each of these statements warrant that they be checked for failure and for possible exceptions since each of these can fail. However such similar blocks of code may be present at 100's of places in a large application and so checking for failure after each line of code would be make it a very lengthy & cumbersome procedure. I was wondering if there is a simpler, elegant way to handle these kind of failures or exceptions. And that's what I wish to ask. Thanks loads everyone.
  2. I make my share of programming design blunders, as many of you know from helping me debug a few, so I am hesitant to point fingers, but I just had an experience so horrible, with so many errors on a website owned by Snapfish (which should have some programming resources) that I had to write it up.
  3. I have purchased a ad manager type script and have put so much work in to the site but i cannot get the cron file to execute properly due to errors. The makers of the script arent answering my emails so I am left to find the answer myself im hoping some experts can shine a light on this for me I have the cron running once daily as required the error messages are as follows: /home2/net2you/public_html/2xx.co.uk/include/CronStats.php: line 1: ?php: No such file or directory /home2/net2you/public_html/2xx.co.uk/include/CronStats.php: line 2: syntax error near unexpected token `;' /home2/net2you/public_html/2xx.co.uk/include/CronStats.php: line 2: `ob_start();' I have installed the script on two different hosts and get the exact same errors. any help would be much appriciated the contents of the cron file are below ______________________________________________ <?php ob_start(); ini_set("max_execution_time", 0); error_reporting(0); require_once("db_connection.php"); // hits table fix $ws = mysql_query("select pid from publishersinfo"); while($row = mysql_fetch_assoc($ws)){ $max = mysql_fetch_assoc(mysql_query("SELECT count(distinct ip) as distinct_hits, count(ip) as hits, date from hits where pub_id='$row[pid]' group by date order by hits desc, distinct_hits desc limit 1")); mysql_query("update publishersinfo set hits = '$max[hits]', distinct_hits = '$max[distinct_hits]' where pid = '$row[pid]' "); $country_clicks = mysql_query("select count(country) as clicks, country from hits where is_click = 1 and pub_id = '$row[pid]' GROUP BY country order by clicks desc"); mysql_query("delete from country_clicks where pid = '$row[pid]' "); while($rc = mysql_fetch_assoc($country_clicks)){ mysql_query("insert into country_clicks set clicks = '$rc[clicks]' , country = '$rc[country]', pid = '$row[pid]', updated = CURDATE() "); } } mysql_free_result($ws); // adv info $advertisement_ids = mysql_query("select adv_id from advertisersinfo"); while($ro = mysql_fetch_assoc($advertisement_ids)){ $clicksToday = mysql_result(mysql_query("select count(hit_id) from hits where adv_id = '$ro[adv_id]' and is_click='1' and is_sale='0' and `date` = CURDATE()"),0,0); $impressionsToday = mysql_result(mysql_query("select count(hit_id) from hits where adv_id = '$ro[adv_id]' and is_click='0' and is_sale='0' and `date` = CURDATE()"),0,0); $conversionsToday = mysql_result(mysql_query("select count(hit_id) from hits where adv_id = '$ro[adv_id]' and is_sale='1' and `date` = CURDATE()"),0,0); mysql_query("update advertisersinfo set clicksToday = $clicksToday, clicksTotal = (clicksTotal + $clicksToday), impressionsToday = $impressionsToday, impressionsTotal = (impressionsTotal + $impressionsToday), conversionsTotal = (conversionsTotal + $conversionsToday) where adv_id = '$ro[adv_id]' "); } mysql_free_result($advertisement_ids); // targeted_ads $cmp_ids = mysql_query("select cmp_id from adv_campaign"); while($ro = mysql_fetch_assoc($cmp_ids)){ $clicksToday = mysql_result(mysql_query("select count(hit_id) from hits where cmp_id = '$ro[cmp_id]' and is_click='1' and `date` = CURDATE()"),0,0); mysql_query("update adv_campaign set clicksToday = $clicksToday, clicksTotal = (clicksTotal + $clicksToday), remaining_budget = (remaining_budget - expense_today) where cmp_id = '$ro[cmp_id]' "); //camp_appeared $camp_appeared = mysql_query("select distinct publishersinfo.url, publishersinfo.pid from publishersinfo, hits where hits.cmp_id= '$ro[cmp_id]' and hits.pub_id=publishersinfo.pid order by hits.hit_id, hits.pub_id"); mysql_query("delete from camp_appeared where cmp_id= '$ro[cmp_id]' "); while($cmp = mysql_fetch_assoc($camp_appeared)){ mysql_query(" insert into camp_appeared set url = '$cmp', pid = '$cmp[pid]', cmp_id = '$ro[cmp_id]', updated = curdate() "); } } mysql_free_result($cmp_ids); /* $as = mysql_query("select ad_id from publishers_adspaces"); while($row = @mysql_fetch_assoc($as)){ $max_one_day_clicks = mysql_result(mysql_query("SELECT count(hit_id) as total from hits where is_click=1 and ad_id='$row[ad_id]' group by date order by total desc limit 1"),0,0); mysql_query("update publishers_adspaces set hits = $max_one_day_clicks "); } mysql_free_result($as); */ $users = mysql_query(" select uid from users where utype = 'pub+adv' "); while($r = mysql_fetch_assoc($users)){ $price = mysql_result(mysql_query("select sum(h.click_price) as price from publishersinfo pi inner join hits h on pi.pid = h.pub_id where pi.uid = '$r[uid]' and h.cmp_id <> 0 and h.date=curdate() and h.is_click=1 "),0,0); mysql_query("delete from pub_earningstoday where uid = '$r[uid]' "); mysql_query("insert into pub_earningstoday set updated = CURDATE(), uid = '$r[uid]', price = '$price' "); } ?>
  4. Hello,recently, the company needed an PHP script to capture error,i try to use “set_error_handler”,but it can’t capture fatal error,like redeclare a function,then I try to change a way that use “register_shutdown_function”,but I found it that also unable to capture above mentioned errors at the end of the script. my php version is 7.0.1
  5. Hi I just finished this tutorial('http://www.startutorial.com/articles/view/php-crud-tutorial-part-3/) and everything was working fine until I decided to add last names to the application. I got everything working on all the other pages except the Update page. This is my php code. d = $_REQUEST['id']; } if ( null==$id ) { header("Location: index.php"); } if ( !empty($_POST)) { // keep track validation errors $nameError = null; $lastError = null; $emailError = null; $mobileError = null; // keep track post values $name = $_POST['name']; $last = $_POST['last']; $email = $_POST['email']; $mobile = $_POST['mobile']; // validate input $valid = true; if (empty($name)) { $nameError = 'Please enter Name'; $valid = false; } $valid = true; if (empty($last)) { $lastError = 'Please enter last name'; $valid = false; } if (empty($email)) { $emailError = 'Please enter Email Address'; $valid = false; } else if ( !filter_var($email,FILTER_VALIDATE_EMAIL) ) { $emailError = 'Please enter a valid Email Address'; $valid = false; } if (empty($mobile)) { $mobileError = 'Please enter Mobile Number'; $valid = false; } // update data if ($valid) { $pdo = Database::connect(); $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $sql = "UPDATE customers set name = ?, last = ?, email = ?, mobile =? WHERE id = ?"; $q = $pdo->prepare($sql); $q->execute(array($name, $last,$email,$mobile,$id)); Database::disconnect(); header("Location: index.php"); } } else { $pdo = Database::connect(); $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $sql = "SELECT * FROM customers where id = ?"; $q = $pdo->prepare($sql); $q->execute(array($id)); $data = $q->fetch(PDO::FETCH_ASSOC); $name = $data['name']; $last = $data['last']; $email = $data['email']; $mobile = $data['mobile']; Database::disconnect(); } ?> When I hit Update it is directing me to a white screen instead of the index.php page.
  6. Ok so I have been working on a simple Bean. My code is: <?php if(!empty($_SESSION['identification'])){ $id = $_SESSION['identification']; $sql = 'SELECT * FROM `accounts` WHERE `id` = $id'; $rows = R::getAll($sql); $accounts = R::convertToBeans('accounts',$rows); if (!isset($accounts->id)) { die("<font color='white'>Bean Cannot be Found!</font>"); } else{ ?> <li><font color="white"><a href="/account">Welcome <?php echo $accounts->username;?></a></font></li> <li><a href="signout.php">Sign out -></a></li> <?php } }?> It dies out the Beans cannot be found. It should have the rows converted to beans however It does not. Any help would be Great. Thank you, The Red Head.
  7. I've just ported a system I wrote a few years back into PHP into a new environment that has PHP 7.1.4 instead of PHP 5.x. My programs used to work perfectly but are now throwing errors, many of which I've never seen before. I am not a fluent PHP programmer although I have programmed in a variety of languages, including Java, so I'm not new to programming by any means. I was reading a short tutorial about PHP error handling and they suggested writing an error-handling function and invoking it as follows: //Error handler function function customError($errno, $errstr, $errfile, $errline, $errcontext) { echo "<b>Error:</b> [$errno] $errstr<br>"; echo "<b>File/Line:</b> $errfile/$errline<br>"; //echo "<b>Error context:</b><br>"; //print_r($errcontext); echo "....Ending Program"; die(); } //Set error handler set_error_handler("customError",E_ALL); I did that and got this: Error: [8] Undefined index: report_layout File/Line: /storage/h13/139/1556139/public_html/SideTrekkedContributions.php/28 In the first line of that, am I correct in assuming that the [8] denotes the severity level of the error, specifically E_NOTICE, which is defined as "Run-time notices. The script found something that might be an error, but could also happen when running a script normally."? Or is the 8 uniquely associated with an "Undefined index" error in a world where every distinct error has a specific number associated with it, like 37 for division by zero and 412 for array index out of bounds? I think it must be the former and that there will be all kinds of errors that have the number 8 but my knowledge of PHP is sketchy so I want to be sure. Now, assuming I'm right and that 8 is the severity of the error, what should one normally do with E_NOTICE errors? Ideally, I'd like PHP not to display this message and I'd like to get rid of the message by doing whatever I need to do to prevent PHP from thinking there's anything wrong (as opposed to telling it not to show me errors below a certain severity). In this particular case, the line of code identified as the source of the error is this: switch($_POST['report_layout']) { I'm darned if I can see what's wrong with this. I never got an error of any kind about this code on the old system. But maybe the old system wanted to show me messages like this but had minor errors suppressed; I really don't know. I tried initializing that variable to null $report_layout = null; but that did NOT keep the error from appearing. I'm at a loss how to satisfy PHP that the variable has been appropriately initialized so it doesn't have to tell me that there's an undefined index. Can anyone enlighten me on the points I've raised?
  8. Dear Professional PHP Coders, I really need your help here. I am designing a form for registration (Please find the codes below). There are two errors I want corrected on this form. 1. PostBack data on controls. If a user submits a form, and there are errors on the submitted data, php should postback the user's submitted data on the controls. Instead of clearing them (i.e., setting the value to empty). 2. Display an array of all errors during form submission. Here, if a user has failed to provide necessary data on a selected controls, php should create an array of all controls wherein there are incorrect data, and php should echo the array of such incorrect errors below the form. (pls find the code below). I have tried something, but php is not echoing the assumed errors. No reporting at all. Please kindly help me. <?php //Connect to the database through our include include_once "/dat/connString_local.php"; //include the php file that checks whether a user is logged in or not include_once("toplinks_for_join_form.php"); //load the captcha code from the database $sql = mysql_query("SELECT id, captchacode, status FROM captcha"); while ($result = mysql_fetch_array($sql)) { $id = $result['id']; $captchacode_from_dbase = $result['captchacode']; } // echo $captchacode_from_dbase; // Set error message as blank upon arrival to page $errorMsg = array(); // First we check to see if the form has been submitted if (isset($_POST['username'])){ // Filter the posted variables // GET USER IP ADDRESS AND LOCATION DATA $ip = preg_replace('#[^0-9.]#', '', getenv('REMOTE_ADDR')); $address1 = str_replace("[^A-Z a-z0-9]", "", $_POST['address1']); $address2 = str_replace("[^A-Z a-z0-9]", "", $_POST['address2']); $address = $address1 .", ". $address2 ." "; //CONCATENATE ADDRESS FIELDS INTO ONE VARIABLE $country = str_replace("[^A-Z a-z0-9]", "", $_POST['country']); // filter everything but spaces, numbers, and letters $state = str_replace("[^A-Z a-z0-9]", "", $_POST['state']); // filter everything but spaces, numbers, and letters $city = str_replace("[^A-Z a-z0-9]", "", $_POST['city']); // filter everything but spaces, numbers, and letters $address .=$city. ", " .$state. ", " .$country; //account info if($_POST['accounttype']=="atm"){ $accounttype = "ATM";}else {$accounttype = "eCurrency";} //$accounttype = str_replace("[^a-z]", "", $_POST['accounttype']); // filter everything but lowercase letters $user_captcha = str_replace("[^0-9]", "", $_POST['captchacode']);//filter everything except numbers only //login data $username = str_replace("[^A-Za-z0-9]", "", $_POST['username']); // filter everything but numbers and letters $email = stripslashes($_POST['email']); $email = strip_tags($email); $email = mysql_real_escape_string($email); $password = str_replace("[^A-Za-z0-9]", "", $_POST['password']); // filter everything but numbers and letters $password2 = str_replace("[^A-Za-z0-9]", "", $_POST['password2']); // filter everything but numbers and letters //bio data $fullname = str_replace("[^A-Za-z]", "", $_POST['fullname']); // filter everything but upper and lowercase letters //find the gender if(($_POST['gender'])=="male"){ $gender = "m";} else {$gender = "f"; } //concatenate the date of birth fields $day = str_replace("[^0-9]", "", $_POST['day']);//filter everything except numbers only $month = str_replace("[^0-9]", "", $_POST['month']);//filter everything except numbers only $year = str_replace("[^0-9]", "", $_POST['year']);//filter everything except numbers only $dob = $year."/".$month."/".$day; //mysql accepts date string starting from year, month then day. $bio = str_replace("[^A-Z a-z0-9]", "", $_POST['bio']); // Check to see if the user filled all fields with // the "Required"(*) symbol next to them in the join form // and print out to them what they have forgotten to put in if(isset($_POST['btn_register'])){ if(!$fullname){$errorMsg[] .= "---Full Name must be characters only and not spaces.<br />";}//die($errorMsg.); else if(!isset($_POST['gender'])){$errorMsg = "---Please select gender.<br />";}//die($errorMsg.= else if(!$day){$errorMsg[] .= "---You must enter your valid date of birth.<br />";}//die($errorMsg. else if(!$month){$errorMsg[] .= "---You must enter your valid date of birth.<br />";}//die($errorMsg.= else if(!$year){$errorMsg[] .= "---You must enter your valid date of birth.<br />";}//die($errorMsg.= else if(!$bio){$errorMsg[] .= "---Please tell us about yourself.";}//die($errorMsg.= else if(strlen($bio) < 100){$errorMsg[] = "---Please tell us about yourself. Minimum of 100 xters.<br />";}//die( else if(!$address1){$errorMsg[] .= "---Address is compulsory please.<br />";}//die($errorMsg.= else if(!$city){$errorMsg[] .= "---Please enter your city location.<br />";}//die($errorMsg.= else if(!$state){$errorMsg[] .= "---Please enter or select a state where you come from.<br />";}//die($errorMsg.= else if(!$country){$errorMsg[] .= "---Please select your country from the list.<br />";}//die($errorMsg.= else if(!$email){$errorMsg[] .= "---You must enter a valid email address.<br />";}//die($errorMsg.= else if(!$username){$errorMsg[] .= "---Your username is required please.<br />";}//die($errorMsg.= else if(!$password){$errorMsg[] .= "---Password is required.<br />";}//die($errorMsg.= else if(strlen($password) < {$errorMsg[] = "---Invalid password. Min of 8 characters are required, max is 20.<br />";}//die( else if(!$password2){$errorMsg[] .= "---Please repeat password.<br />";}//die($errorMsg.= else if($user_captcha!=$captchacode_from_dbase){$errorMsg[] .= "---Please enter the correct CAPTCHA code.<br />";}//die($errorMsg.= else if(!$accounttype){$errorMsg[] .= "---Please select account type or mode of transaction.<br />";}//die($errorMsg.= else if(!$ip){$errorMsg[] .= "---Your location cannot be determined. You will not be allowed to continue the registration.<br />";}//die( elseif($country=="Select your country"){$errorMsg[] .= "Invalid Country selection.<br />";} else if($accounttype=="Select account type"){$errorMsg[] .= "Invalid Account Type selection.<br />";} //die($errorMsg); else if($password!=$password2){$errorMsg[] .= "---Passwords did not match. Repeat correct passwords please.<br />";}//die( else if($month > 12){$errorMsg[] .= "---Invalid month in date of birth.<br />";}//die( else if($day > 31 || $day =="00"){$errorMsg[] .= "---Invalid day of birth.<br />";}//die( else if($year < 1960 || $year > 1995 ){$errorMsg[] .= "---You are not qualified for this registration.<br />";}//die( else { //update the captcha table with a new generated captcha code // this file regenerates the captcha code if it is less than 50. require("update_captcha.php"); // Database duplicate Fields Check $sql_username_check = mysql_query("SELECT id FROM members WHERE username='$username' LIMIT 1"); $sql_email_check = mysql_query("SELECT id FROM members WHERE email='$email' LIMIT 1"); $username_check = mysql_num_rows($sql_username_check); $email_check = mysql_num_rows($sql_email_check); if($username_check > 0){ $errorMsg = "<u>ERROR:</u><br />Sorry, our system does not accept the username that you are using. Please try another."; die($errorMsg); } else if($email_check > 0){ $errorMsg = "<u>ERROR:</u><br />Sorry, our system does not accept the email that you are using. Please try another."; die($errorMsg);} } }//close the blocked if(isset)else { // Add MD5 Hash to the password variable $hashedPass = md5($password); // Add user info into the database table, claim your fields then values $sql = mysql_query("INSERT INTO members (fullname,gender,dob,bio,ip,username,address,country,state,city,accounttype,email, password, signup_date) VALUES('$fullname', '$gender','$dob','$bio','$ip','$username','$address','$country','$state','$city','$accounttype','$email','$hashedPass', now()) ") or die (mysql_error()); // Get the inserted ID here to use in the activation email $id = mysql_insert_id(); // Create a directory(folder) to hold each user files(pics, MP3s, etc.) mkdir("memberFiles/$id", 0755); //echo "Yes, " .$_POST['btn_register']. "<br />Username: ".$_POST['username']. "<br />Gender: ". $gender. "<br />Captcha: ". $user_captcha. //"<br />Account Type: ".$accounttype. "<br />Address: ".$address; //send the maill first before adding to the database //compose email function here $to = "$email"; $subject = "Complete your registration - Authentication Needed!"; //Begin HTML Email Message where you need to change the activation URL inside $message = '<html> <body bgcolor="#FFFFFF"> Hi ' . $fullname . ', <br /><br /> You have successfully created an account with us.<br /><br /> Your Login information is as follows: <br /><br /> Your E-mail Address: ' . $email . ' <br /> Your Password: ' . $password . ' <br /><br /> Your Account / Payment / Transaction information: '.$accounttype. '. <br /><br /> In order to be able to use your account, you must complete this step to activate your account by clicking on the Account Activation Link below. <br /><br /> Please click the link to activate now >> <a href="http://localhost/easytimecorporation.com/lotto/activation.php?id=' . $id . '"> ACTIVATE NOW</a><br /> Thanks! <br /><br /> Eyo Honesty, <br /> Easytime Corporation. </body> </html>'; // end of message //import the email settings file here. include_once('emailSettings.php'); //check whether the mail is sent or not if($mail->Send()) { //echo "Message has been sent"; // Then print a message to the browser for the joiner $message2 = '<br /> Hi ' . $fullname . ', <br /><br /> You have successfully created an account with us. A mail has been sent to you at ' .$email. '.<br /><br /> In order to be able to use your account, please check your email and click on the Account Activation Link to activate your account. <br /><br /> Thank you'; //echo $message2; //update the captcha table with a new generated captcha code // this file regenerates the captcha code if it is less than 50. require("update_captcha.php"); //redirect user to success.php $_SESSION['msg'] = $message2; //echo $_SESSION['msg']; //header("location: register_success.php?id=".$_SESSION['msg']); } else { //delete the user from database and delete the created user directory require("delete_user.php"); rmdir("memberFiles/$id");//removes a created directory. //update the captcha table with a new generated captcha code // this file regenerates the captcha code if it is less than 50. require("update_captcha.php"); die("Message was not sent <br />PHPMailer Error: " . $mail->ErrorInfo); exit(); } // Exit so the form and page does not display, just this success message }//close the $_POST[''] check line ?> <!DOCTYPE html> <HTML> <HEAD> <META CHARSET="UTF-8"> <LINK rel="icon" href="images/blueweb.ico" type="image/x-icon"> <LINK rel="stylesheet" href="style/style.css"> <TITLE>Users Registration Form.</TITLE> <STYLE type="text/css"> <!-- .style1 {color: #FF0000} .style3 {color: #FF0000; font-weight: bold; } --> </STYLE> </HEAD> <BODY> <?php include_once("template_pageTop.php");?> <DIV id="pageMiddle"> <FORM name="joinForm" id="joinForm" action="join_form.php" method="post" enctype="multipart/form-data"> <DIV align="center"> <H1>Users Registration Form</H1> <HR style="width:80%; outline-style:groove; outline-color:#CCCCCC;"> <DIV align="justify"> <LEGEND style="margin-left:20px; "><STRONG><u>Basic Data</u></STRONG> Please all starred <SPAN class="style1">*</SPAN> fields in red colour are required.</LEGEND> <BR /> <TABLE width="800" border="0" align="center" cellpadding="2" cellspacing="5" style="border-radius:10px; background-color:#006699; color:#FFFFFF;"> <TR> <TD align="right" valign="middle" style="width:260px; height:40px; padding:15px;"><SPAN class="style3">*</SPAN><STRONG> Full Name:</STRONG></TD> <TD width="520" align="left" valign="middle"><INPUT type="text" name="fullname" value="<?php if (isset($_POST['fullname'])) {echo "$fullname";} ?>" size="80" maxlength="40"></TD> </TR> <TR> <TD align="right" valign="middle" style="width:260px; height:40px; padding:15px;"><SPAN class="style3">*</SPAN><STRONG> Gender:</STRONG></TD> <TD width="520" align="left" valign="middle"> <LABEL> <INPUT type="radio" name="gender" value="male"> Male</LABEL> <INPUT type="radio" name="gender" value="female"> Female</LABEL></TD> </TR> <TR> <TD align="right" valign="middle" style="width:260px; height:40px; padding:15px;"><SPAN class="style3">*</SPAN><STRONG> Date of Birth:</STRONG></TD> <TD width="520" align="left" valign="middle"> Day <INPUT type="text" name="day" value="<?php if (isset($_POST['day'])) {echo "$day";} ?>" size="5" maxlength="2"> Month <INPUT type="text" name="month" value="<?php if (isset($_POST['month'])) {echo "$month";} ?>" size="5" maxlength="2"> Year <INPUT type="text" name="year" value="<?php if (isset($_POST['year'])) {echo "$year";} ?>" size="10" maxlength="4"> format --> DD / MM / YYYY </TD> </TR> <TR> <TD align="right" valign="middle" style="width:260px; height:40px; padding:15px;"><STRONG><SPAN class="style1">*</SPAN> Tell us about yourself: </STRONG><EM>(min = 100 characters).</EM> </TD> <TD width="520" align="left" valign="middle"><TEXTAREA name="bio" cols="50" rows="4"><?php if (isset($_POST['bio'])) {echo "$bio";} ?></TEXTAREA></TD> </TR> </TABLE> </DIV> <HR style="width:80%; outline-style:groove; outline-color:#CCCCCC;"> <DIV align="justify"> <LEGEND style="margin-left:20px; "><STRONG><u>Location Data</u></STRONG> Please all starred <SPAN class="style1">*</SPAN> fields in red colour are required.<BR> </STRONG></u></LEGEND><BR /> <TABLE width="800" border="0" align="center" cellpadding="2" cellspacing="5" style="border-radius:10px; background-color:#006699; color:#FFFFFF;"> <TR> <TD align="right" valign="middle" style="width:260px; height:40px; padding:15px;"><SPAN class="style3">*</SPAN><STRONG> Address 1 :</STRONG></TD> <TD><INPUT name="address1" type="text" size="80" maxlength="70" value="<?php if (isset($_POST['address1'])) {echo "$address1";} ?>" /></TD> </TR> <TR> <TD align="right" valign="middle" style="width:260px; height:40px; padding:15px;"><STRONG>Address 2 (<EM>optional</EM>) :</STRONG></TD> <TD><INPUT name="address2" type="text" size="80" maxlength="70" value="<?php if (isset($_POST['address2'])) {echo "$address2";} ?>" /></TD> </TR> <TR> <TD align="right" valign="middle" style="width:260px; height:40px; padding:15px;"><SPAN class="style3">*</SPAN><STRONG> City:</STRONG></TD> <TD><INPUT name="city" type="text" size="50" maxlength="30" value="<?php if (isset($_POST['city'])) {echo "$city";} ?>" /></TD> </TR> <TR> <TD align="right" valign="middle" style="width:260px; height:40px; padding:15px;"><SPAN class="style3">*</SPAN><STRONG> State:</STRONG></TD> <TD><INPUT name="state" type="text" size="50" maxlength="25" value="<?php if (isset($_POST['state'])) {echo "$state";} ?>" /></TD> </TR> <TR> <TD align="right" valign="middle" style="width:260px; height:40px; padding:15px;"><SPAN class="style3">*</SPAN><STRONG> Country :</STRONG></TD> <TD><SELECT name="country"> <OPTION value="Select your country" selected="selected">Select your country</OPTION> <OPTION value="Australia">Australia</OPTION> <OPTION value="Canada">Canada</OPTION> <OPTION value="Mexico">Mexico</OPTION> <OPTION value="United Kingdom">United Kingdom</OPTION> <OPTION value="United States">United States</OPTION> <OPTION value="Zimbabwe">Zimbabwe</OPTION> <OPTION value="Cameroon">Cameroon</OPTION> <OPTION value="Nigeria">Nigeria</OPTION> <OPTION value="South Africa">South Africa</OPTION> <OPTION value="Uganda">Uganda</OPTION> <OPTION value="Thailand">Thailand</OPTION> <OPTION value="Brazil">Brazil</OPTION> <OPTION value="China">China</OPTION> <OPTION value="Japan">Japan</OPTION> <OPTION value="Korea">Korea</OPTION> <OPTION value="DR Congo">DR Congo</OPTION> <OPTION value="Egypt">Egypt</OPTION> <OPTION value="Germany">Germany</OPTION> <OPTION value="Bene Republic">Bene Republic</OPTION> <OPTION value="Niger">Niger</OPTION> <OPTION value="Saudi Arabia">Saudi Arabia</OPTION> <OPTION value="Italy">Italy</OPTION> <OPTION value="France">France</OPTION> <OPTION value="India">India</OPTION> <OPTION value="Malaysia">Malaysia</OPTION> <OPTION value="Spain">Spain</OPTION> <OPTION value="Portugal">Portugal</OPTION> <OPTION value="Port De Spain">Port De Spain</OPTION> <OPTION value="Trinidad and Tobago">Trinidad and Tobago</OPTION> <OPTION value="Chile">Chile</OPTION> </SELECT></TD> </TR> </TABLE> </DIV> <HR style="width:80%; outline-style:groove; outline-color:#CCCCCC;"> <DIV align="justify"> <LEGEND style="margin-left:20px; "><U><STRONG>Login Information</STRONG></U> Please all starred <SPAN class="style1">*</SPAN> fields in red colour are required.</LEGEND> <BR /> <TABLE width="800" border="0" align="center" cellpadding="2" cellspacing="5" style="border-radius:10px; background-color:#006699; color:#FFFFFF;"> <TR> <TD align="right" valign="middle" style="width:260px; height:40px; padding:15px;"><SPAN class="style3">*</SPAN><STRONG> Username:</STRONG></TD> <TD><DIV align="left"> <INPUT name="username" type="text" size="50" maxlength="25" value="<?php if (isset($_POST['username'])) { echo "$username";} ?>" /> </DIV></TD> </TR> <TR> <TD align="right" valign="middle" style="width:260px; height:40px; padding:15px;"><P><SPAN class="style3">*</SPAN><STRONG> Password: </STRONG></P> <P><EM>(8 characters minimum, 20 max.) </EM></P></TD> <TD><DIV align="left"> <INPUT name="password" type="password" value="<?php if (isset($_POST['password'])) {echo "$password";} ?>" size="40" maxlength="20"> No spaces or special charactes. </DIV></TD> </TR> <TR> <TD align="right" valign="middle" style="width:260px; height:40px; padding:15px;"><P><SPAN class="style3">*</SPAN><STRONG> Repeat Password</STRONG></P> <P><EM>(8 characters minimum, 20 max.) </EM></P></TD> <TD><DIV align="left"> <INPUT name="password2" type="password" value="<?php if (isset($_POST['password2'])) {echo "$password2";} ?>" size="40" maxlength="25"> No spaces or special charactes. </DIV></TD> </TR> <TR> <TD align="right" valign="middle" style="width:260px; height:40px; padding:15px;"><SPAN class="style3">*</SPAN><STRONG> E-mail Address</STRONG></TD> <TD><DIV align="left"> <INPUT name="email" type="text" value="<?php if (isset($_POST['email'])) {echo "$email";} ?>" size="80" maxlength="45" /> </DIV></TD> </TR> </TABLE> </DIV> <HR style="width:80%; outline-style:groove; outline-color:#CCCCCC;"> <DIV align="justify"> <LEGEND style="margin-left:20px; "><U><STRONG>Account / Payment Information</STRONG></U> Please all starred <SPAN class="style1">*</SPAN> fields in red colour are required.</LEGEND> <BR /> <TABLE width="800" border="0" align="center" cellpadding="2" cellspacing="5" style="border-radius:10px; background-color:#006699; color:#FFFFFF;"> <TR> <TD align="right" valign="middle" style="width:260px; height:40px; padding:15px;"><SPAN class="style3">*</SPAN><STRONG> Account Type:</STRONG></TD> <TD><SELECT name="accounttype" size="3"> <OPTION value="Select account type">Select Account Type</OPTION> <OPTION value="atm">ATM</OPTION> <OPTION value="ecurrency" selected>e-Currency</OPTION> </SELECT></TD> </TR> <TR> <TD align="right" valign="middle" style="width:260px; height:40px; padding:15px;"><SPAN class="style3">*</SPAN><STRONG> CAPTCHA:</STRONG></TD> <TD> <INPUT name="captchacode" type="text" value="<?php if (isset($_POST['captchacode'])) {echo "$user_captcha";}?>" maxlength="12"> <?php echo "<font style ='color:#ffff00; font-size:20px; font-weight:bolder; font:Broadway;'> $captchacode_from_dbase</FONT> <font style='color:#ffffff;'-->Enter the code shown.</FONT>";?> </TD> </TR> </TABLE> </DIV> <HR style="width:80%; outline-style:groove; outline-color:#CCCCCC;"> <DIV align="left" style="margin-left:0px;"> <DIV align="center"> <INPUT name="btn_register" type="submit" value="R E G I S T E R"> <INPUT name="reset" type="reset" value="R E S E T" style="font:Georgia, 'Times New Roman', Times, serif; font-size:14px;"> <BR /><BR /> </DIV> </DIV> <?php if (empty($errorMsg)=== false) { echo '<ul>'; foreach($errorMsg as $error) { echo '<li>', $error, '</li>'; } echo '</ul>'; } ?> </FORM> </DIV> <?php include_once("template_pageBottom.php");?> </BODY> </HTML> join_form.php
  9. Hi All, I have touched upon exceptions earlier. However I am still not sure if I am handling them correctly. try { ... ... ... }catch(Exception $e){ if($prod === true) // In production mode { header("Location: exceptions/errors.php") exit(); } if($dev === true) // In development mode { echo $e->getMessage(); // & if needed log the errors / exceptions into a file. exit(); } } I would like to ask if using the function header() to load the errors.php page is a good and safe practice. Or is there a better way to load the errors.php. If I load the errors page as in the snippet, do I also have to log the errors myself in some files or is php going to do that in any case. Any improvements or suggestions are welcome. Thanks all ! P.S. Googling exceptions gives loads of information but seldom does it touch the issue of loading an errors page when an exception occurs.
  10. [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?
×

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.