PHP - Please Help Me To Solve These Coding Errors
I have following errors in below coding. Can anyone point out me where i went wrong??
Undefined variables: fname,focu,foad,ftp,fmf,mname,mocu,moad,mtp,mmf,gname,gocu,goadd,gtp,gmf in C:\wamp\www\Student registration\manage studnt parent details\manageStudentRegistrationParentDetailsForm.php manageStudentRegistrationParentDetailsForm.php Code: [Select] <?php $query="SELECT state,name,occupation,office_address,office_telephone,mobile_number FROM parent_info where admission_no='$admission_no'"; $result=mysql_query($query); while($row=mysql_fetch_array($result)){ $first=$row['state']; if($first=='father'){ $fname=$row['name']; $focu=$row['occupation']; $foadd=$row['office_address']; $ftp=$row['office_telephone']; $fmf=$row['mobile_number']; } if($first=='mother'){ $mname=$row['name']; $mocu=$row['occupation']; $moadd=$row['office_address']; $mtp=$row['office_telephone']; $mmf=$row['mobile_number']; } if($first=='guardians'){ $gname=$row['name']; $gocu=$row['occupation']; $goadd=$row['office_address']; $gtp=$row['office_telephone']; $gmf=$row['mobile_number']; } } ?> ---- ---- <tr> <td> </td> <td colspan="5"><h3> <label><strong>Parents/Guardian information</strong></label> <strong> </strong></h3></td> <td> </td> </tr> <tr> <td> </td> <td colspan="2"> </td> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td><label>Admission No</label> </td> <td colspan="2" align="left"><?php echo $admission_no ;?></td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td colspan="2"> </td> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td colspan="2"> <input type="checkbox" name="checkbox" id="checkbox" <?php if($fname!=null){ ?> checked="checked" <?php }?> onclick="father()" /> <label>fathers details</label></td> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td colspan="2"><label> Name</label> </td> <td><input type="text" name="Name1" id="textfield" value="<?php echo $fname; ?>" disabled="disabled" /></td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td colspan="2"><label>Occupation</label> </td> <td> <input type="text" name="Occupation1" id="textfield2" value="<?php echo $focu; ?>" disabled="disabled"/> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td colspan="2"><label>Office Address</label> </td> <td> <textarea name="Office_Address1" id="office_address" cols="45" rows="5" disabled="disabled"><?php echo $foadd; ?></textarea> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td colspan="2"><label>Office Telephone Number</label> </td> <td> <input type="text" name="Office_tel1" id="textfield4" value="<?php echo $ftp; ?>" disabled="disabled" /> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td colspan="2"><label>Mobile Phone Number</label></td> <td> <input type="text" name="Mobile_pho1" id="textfield5" value="<?php echo $fmf; ?>" disabled="disabled" /> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td colspan="2"> </td> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td colspan="2"> <input type="checkbox" name="checkbox2" id="checkbox2" <?php if($mname!=null){ ?> checked="checked" <?php }?> onclick="mother()" /> <label>Mothers details</label></td> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td colspan="2"><label> Name</label> </td> <td> <input type="text" name="Name2" id="textfield3" value="<?php echo $mname; ?>" disabled="disabled"/> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td colspan="2"><label>Occupation</label> </td> <td> <input type="text" name="Occupation2" id="textfield7" value="<?php echo $mocu; ?>" disabled="disabled"/> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td colspan="2"><label>Office Address</label> </td> <td> <textarea name="Office_Address2" id="textarea" cols="45" rows="5" disabled="disabled"><?php echo $moadd; ?></textarea> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td colspan="2"><label>Office Telephone Number</label> </td> <td> <input type="text" name="Office_tel2" id="textfield8" value="<?php echo $mtp; ?>" disabled="disabled" /> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td colspan="2"><label>Mobile Phone Number</label> </td> <td> <input type="text" name="Mobile_pho2" id="textfield9" value="<?php echo $mmf; ?>" disabled="disabled" /> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td colspan="2"> </td> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td colspan="2"> <input type="checkbox" name="checkbox3" id="checkbox3" <?php if($gname!=null){ ?> checked="checked" <?php }?> onclick="Guardian()"/> <label>Guardian details</label></td> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td colspan="2"><label> Name</label> </td> <td> <input type="text" name="Name3" id="textfield6" value="<?php echo $gname; ?>" disabled="disabled"/> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td colspan="2"><label>Occupation</label> </td> <td> <input type="text" name="Occupation3" id="textfield10" value="<?php echo $gocu; ?>" disabled="disabled"/> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td colspan="2"><label>Office Address</label> </td> <td> <textarea name="Office_Address3" id="textarea2" cols="45" rows="5" disabled="disabled"><?php echo $goadd; ?></textarea> </td> <td> </td> <td> </td> <td> </td></tr> <tr> <td> </td> <td colspan="2"><label>Office Telephone Number</label> </td> <td> <input type="text" name="Office_tel3" id="textfield11" value="<?php echo $gtp; ?>" disabled="disabled"/> </td> <td> </td> <td> </td> <td> </td> </tr> <tr><td> </td> <td colspan="2"><label>Mobile Phone Number</label> </td> <td> <input type="text" name="Mobile_pho3" id="textfield12" value="<?php echo $gmf; ?>" disabled="disabled" /> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td colspan="2"> </td> <td></td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td colspan="2"> </td> <td> <input type="submit" name="button" id="button" value="Save" /> </td> <td> </td> <td> </td> <td> </td> </tr> </table> <p> </p> <p> </p></td> </tr> Similar TutorialsHi there, I am experiencing a few errors in the php sections and can not really see any obvious problems with the php lines.. Please your help would be appreciated.. Code: [Select] <?php session_start(); if($_REQUEST['username'] == "rotten" && $_REQUEST['password'] == "1212"){ $_SESSION['username'] = "rotten"; $_SESSION['password'] = "1212"; header("Location: home.php ".$_SESSION['pageredirect']); }else{ $_SESSION['displayerror'] = "0"; header("Location: "); // I want users to stay on the same page which is page3 I called it, so If I do specify the page in header("location":........) it will break the page for some reasons. } ?> This is the message that is coming up when I try executing the code --> Notice: Undefined index: username in C:\wamp\www\prac4\login.php on line 3 hey anyone know how to fix the problem im having with my code? the first 10 lines of code is working great and doing what it should do but the rest of the code is not doing what i want it to do. what im trying to get it to do is select the packagelink from the database and go to that link thanks... Code: [Select] <?PHP $username1 = @$HTTP_GET_VARS["username"]; $actnum1 = @$HTTP_GET_VARS["actnum"]; include("cfg.php"); $query = "Select * from ".$DBprefix."signup where username='$user_name1' And actnum='$actnum1'"; $result = mysql_query($query); if ($row = mysql_fetch_array($result)){ $query = "UPDATE ".$DBprefix."signup Set actnum = '0' where username='$username1'"; $result = mysql_query($query); $query = "Select * from ".$DBprefix."signup where username='$username1'"; $result = mysql_query($query); //CODE BELOW IS WHAT IM HAVING THE PROBLEM WITH// $result = mysql_query ("Select packages from ".$DBprefix."signup where username='$username1'"); $package = '$result'; $result2 = mysql_query("SELECT packagelink FROM packages WHERE packages ='$package'"); $link = '$result'; header("Location: '$link'"); } ?> Hi there, i am not sure if i am in the right place for this but i have a Community website that i run but the coder has now left and im not sure what has happened to the site. Myselve and a mate have looked over it and had a few tips to help remove some errors but we aint no coders or have really good knoledge of PHP or MYSQL... If anyone could help i would really appreciate it as i need to get this site back running again. I dont think its anything major for someone that knows what they are doing but for me its a big mess im not sure if i am allowed to link you to the site so you can see what i mean but if i am then please ask and i will post the link... Thanks i seem to get the following errors: Notice: Undefined index: submit in C:\wamp\www\registration\register.php on line 12 Notice: Undefined index: fullname in C:\wamp\www\registration\register.php on line 14 Notice: Undefined index: username in C:\wamp\www\registration\register.php on line 15 Notice: Undefined index: password in C:\wamp\www\registration\register.php on line 16 Notice: Undefined index: repeat_password in C:\wamp\www\registration\register.php on line 17 its only in the php section that i am getting them <?php //Form Data echo "<h1>Registration</h1>"; $submit = $_POST['submit']; $fullname = $_POST['fullname']; $username = $_POST['username']; $password = $_POST['password']; $repeat_password = $_POST['repeat_password']; if ($submit) { } ?> <html> <form action='register.php' method='POST'> <table> <tr> <td> Choose a Username: </td> <td> <input type='text' name="username"> </td> </tr> <tr> <td> Password: </td> <td><input type='password' name="password"> </td> </tr> <tr> <td> Repeat Your Password: </td> <td><input type='password' name="repeat_password"> </td> </tr> <tr> <td> Your Full Name: </td> <td><input type='text' name="name"> </td> </tr> </table> <p><input type='submit' name='submit'></p> </form> </html> Can some PHP guru help me with this scenarios? I've been wondering around these for hours and can't find my way around it. Please... 1. Write a function in PHP that takes three parameters (representing day, month and year) and calculates the day/month/year of the following day (for example, if the parameter is 31/10/2010, the result should be 01/11/2010). No need to take into account leap years. You cannot use any date/time specific functions, you must do it "by hand" (no built-in functions).. 2. Write a function in PHP that takes a string and counts the number of occurrences of any given letter in it (for example, given the string "HELLO" as a parameter, there are two occurrences of "L", one of "H", one of "E", one of "O" and zero of any other character). Code: [Select] Warning: SimpleXMLElement::addChild() [simplexmlelement.addchild]: unterminated entity reference limit=50&method=GET&access_token=AAACd5Mcn7VQBAKaupEZCocujRuoBzzWeZCj945ZApHEsv5BZAxZCJfS62cSSz4txlZBUZAec03GcjpHdk0NTotnglt2ZB41GzzeYl8xqIZBmsvlS6UZAoHZB1A4&offset=50 in /home/content/71/8432771/html/facebook/get/friends.php on line 62 Code: [Select] <?php /** * Copyright 2011 Facebook, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may * not use this file except in compliance with the License. You may obtain * a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations * under the License. */ require '../../src/facebook.php'; // Create our Application instance (replace this with your appId and secret). $facebook = new Facebook(array( 'appId' => 'APPID', 'secret' => 'SECRET', )); // Get User ID $user = $facebook->getUser(); // We may or may not have this data based on whether the user is logged in. // // If we have a $user id here, it means we know the user is logged into // Facebook, but we don't know if the access token is valid. An access // token is invalid if the user logged out of Facebook. if ($user) { try { // Proceed knowing you have a logged in user who's authenticated. $user_profile = $facebook->api('/me/friends?fields=id,name,first_name,last_name,picture&limit=50'); } catch (FacebookApiException $e) { error_log($e); $user = null; } } // Login or logout url will be needed depending on current user state. if ($user) { $logoutUrl = $facebook->getLogoutUrl(); } else { $loginUrl = $facebook->getLoginUrl(); } $profile = array ($user_profile); $xml = new SimpleXMLElement('<root/>'); arrayToXML( $xml, $profile ); echo $xml->asXML(); function arrayToXML( SimpleXMLElement &$xml, $array ) { foreach( $array as $name => $value ) { if( !is_array($value) ) $xml->addChild( $name, $value ); else { $child = $xml->addChild( $name ); <----------------------------------------------LINE 64 arrayToXML( $child, $value ); } } } ?> Here is the array Code: [Select] { "data": [ { "name": "Pauline Latty", "id": "312293" }, { "name": "Noah Ethan Schinasi", "id": "55101245" }, { "name": "Luis Guerrero", "id": "194803212" }, { "name": "Nakia Johnson", "id": "500350828" }, { "name": "Bethany Vallerie", "id": "502062429" }, { "name": "Caroline Franks", "id": "505331027" }, { "name": "Andrew Shivers", "id": "505749817" }, { "name": "Sandra G Garcia", "id": "508006303" }, { "name": "Catherine Davis", "id": "511006416" }, { "name": "Marc Watson", "id": "511201074" }, { "name": "Laura Clarke", "id": "513653820" }, { "name": "Amanda Rice", "id": "514062403" }, { "name": "Scott Alan Buss", "id": "514197867" }, { "name": "Evangelist Josephus", "id": "515837621" }, { "name": "Chet Fontenot", "id": "516199085" }, { "name": "Sharon Howard", "id": "516580144" }, { "name": "Chatt Franco", "id": "517211511" }, { "name": "Lydgia Vanessa Staples", "id": "518094760" }, { "name": "Corry Bell", "id": "521043483" }, { "name": "Lessie Tyson", "id": "521855454" }, { "name": "Jawahar Peter", "id": "523159934" }, { "name": "Sheena Shiko", "id": "523461577" }, { "name": "Pat Larry Thomas", "id": "523555768" }, { "name": "Oyenuga Kunle Johnson Matthew", "id": "524263978" }, { "name": "Angela Whitten", "id": "524631356" } ], "paging": { "next": "https://graph.facebook.com/me/friends?limit=25&access_token=2227470867|2.AQAMMvJya05xkLhR.3600.1318057200.0-100001957015772|IUAhNlekyalf7sxy-OjdJd7KCwo&offset=25" } } its that paging, I can not seem to get that to work yet. This is how it should look. basic xml file http://wiistream.net/php/user/pictures/gallery.xml but this is how it looks. http://wiistream.net/php/user/pictures/gallery.php?username=Mancent&user_folder=Mancent_Pictures mysql php xml file with category's. This is whats making it so hard the category's Im using 3 tables one table is for my friends and one table is the category folder name and the other table is the picture holder with the category folder name so I thought i could do a if statement if user_folder = user_folder from the two tables it would keep the correct images in the correct category. But 3 weeks later still no luck. Heres what I got so far. <?php //lets get the mysql connection information. include "../../connect.php"; //we need this because the flash stores the xml file in temp internet history. Header('Cache-Control: no-cache'); Header('Pragma: no-cache'); //ok flash sent out the username $username = mysql_real_escape_string($_GET['username']); //ok flash sent out the folder name $user_folder = mysql_real_escape_string($_GET['user_folder']); $user_folder = (isset($_GET['friend'])) ? ' AND b.user_folder = \'' . mysql_real_escape_string($_GET['user_folder']) . '\' ' : NULL; //this part will be used becasue we need to see if friendship has ben made. $friend = (isset($_GET['friend'])) ? ' AND b.friend = \'' . mysql_real_escape_string($_GET['friend']) . '\' ' : NULL; //Ok lets select the username from the accounts table to see if they are a user.. $get_username = "SELECT * FROM accounts WHERE username = '$username'"; $username_results = mysql_query($get_username) or die("Data not found."); //Get the number of results from the query. $check_username_mysql_rows = mysql_num_rows($username_results); //If there is a match for the username, echo the the users xml data. if($check_username_mysql_rows == 1) { $sql1 = "SELECT a.username,a.user_folder,b.username FROM user_image_folders as a JOIN `user_friends_list` as b ON (b.friend = a.username)WHERE (b.username = '$username' $user_folder $friend AND b.status = 1)"; $result1 = mysql_query($sql1); //TODO MAKE THE FRIENDSHIP WORK WITH THIS $sql = "SELECT a.username,a.user_folder,a.user_folder,a.large_pic,a.small_pic,a.pic_title,a.pic_discription,b.username FROM user_photo_gallery as a JOIN `user_friends_list` as b ON (b.friend = a.username)WHERE (b.username = '$username' $user_folder $friend AND b.status = 1)"; $result2 = mysql_query($sql); $user_xml = "<?xml version=\"1.0\"?>\n"; $user_xml .= "<settings>\n"; $user_xml .= "<sceneHeight>600</sceneHeight>\n"; $user_xml .= "<sceneWidth>1000</sceneWidth>\n"; $user_xml .= "<titleColor>#000000</titleColor>\n"; $user_xml .= "<descriptionBgAlpha>70</descriptionBgAlpha>\n"; $user_xml .= "<showFullscreenBtn>no</showFullscreenBtn>\n"; $user_xml .= "<waterMark useImage=\"no\"><![CDATA[THIS]]></waterMark>\n"; $user_xml .= "</settings>\n"; $user_xml .="<galleries>\n"; //{ while ($i_get_myfriends = mysql_fetch_assoc($result1)) { $user_xml .="<gallery theName=\"". $i_get_myfriends['user_folder'] ."\" itemsPerRow=\"3\" autoStart=\"no\" playTime=\"5\" autoResize=\"yes\" xOffset=\"5\" yOffset=\"10\" showTitleOnThumbs=\"yes\" allowDownload=\"yes\">\n"; while ($i_get_myfriends2 = mysql_fetch_assoc($result2)) { //if($i_get_myfriends['user_folder'] ==$i_get_myfriends2['user_folder']) //{ $user_xml .="<picture largePicture=\"". $i_get_myfriends2['large_pic'] ."\" smallPicture=\"". $i_get_myfriends2['small_pic'] ."\" theTitle=\"". $i_get_myfriends2['pic_title'] ."\"><![CDATA[". $i_get_myfriends2['pic_discription'] ."]]>\n"; $user_xml .="</picture>\n"; //} } $user_xml .="</gallery>\n"; } $user_xml .="</galleries>\n"; echo $user_xml; } else { echo "Wiistream Eorror!\n"; } ?> See all the images are going into one folder.. and they are sopost to go into the friends folder it they are the friends pictures. but they are all in my folder.. My code is $answer = (1/212500); output is 4.90205690308E-6 while I need I output as 0.00000470588 Please help, and tell me what is the specific problem, This topic has been moved to Third Party PHP Scripts. http://www.phpfreaks.com/forums/index.php?topic=306725.0 Hi, My hosting company (Bluehost) told me when someone goes to my home page, it sends these series of queries and this is the reason for my high cpu usage and this is why my site says Error Establishing Database. The hosting company gave me these: Each script is using a decent about of CPU. [2:09:33 AM] hollane3 31881 6.2 0.1 186084 49000 ? RN 01:59 0:26 | \_ /ramdisk/bin/php5 /home4/hollane3/public_html/index.php hollane3 934 6.6 0.1 184012 48652 ? RN 01:59 0:25 | \_ /ramdisk/bin/php5 /home4/hollane3/public_html/index.php hollane3 5344 7.1 0.1 184008 48440 ? RN 02:01 0:21 | \_ /ramdisk/bin/php5 /home4/hollane3/public_html/wp-cron.php hollane3 5164 7.1 0.1 186444 48772 ? RN 02:01 0:22 | \_ /ramdisk/bin/php5 /home4/hollane3/public_html/index.php hollane3 7246 6.9 0.1 184116 48196 ? RN 02:02 0:18 | \_ /ramdisk/bin/php5 /home4/hollane3/public_html/index.php hollane3 11221 5.8 0.1 185160 47852 ? RN 02:03 0:09 | \_ /ramdisk/bin/php5 /home4/hollane3/public_html/index.php hollane3 11236 6.4 0.1 182992 47620 ? RN 02:03 0:10 | \_ /ramdisk/bin/php5 /home4/hollane3/public_html/wp-cron.php hollane3 12595 5.4 0.1 183088 47264 ? RN 02:04 0:07 | \_ /ramdisk/bin/php5 /home4/hollane3/public_html/index.php hollane3 13969 5.4 0.1 184648 47396 ? RN 02:04 0:05 | \_ /ramdisk/bin/php5 /home4/hollane3/public_html/index.php hollane3 14161 6.1 0.1 182480 47140 ? RN 02:04 0:06 | \_ /ramdisk/bin/php5 /home4/hollane3/public_html/wp-cron.php hollane3 14198 6.7 0.1 183092 47204 ? RN 02:04 0:06 | \_ /ramdisk/bin/php5 /home4/hollane3/public_html/index.php hollane3 16343 4.9 0.1 181968 46496 ? RN 02:05 0:02 | \_ /ramdisk/bin/php5 /home4/hollane3/public_html/index.php I am not well versed with scripting, so I don't know what this mean. Can anyone PLEASE help me to answer these questions: + Is this related to a particular plugin or widget or theme? + What could be the possible source of this issue, that is, which file should I look at to resolve this? + Can I fix this myself or do I need a php coder to help me? Thanks! Hello guys, I'm trying to solve my hometask . I tried in many different ways to solve the task related with Advanced SQL Syntax. Please check the pic below: The Quiz is asking for make location appear in all uppercase letters, the character associated with a given ASCII value and the table is people. I tried the last one in this way: SELECT CONCAT(name,'is from',strtoupper(location),' The ASCII character of the number ',number,' is ',ASCII(number)) FROM `people` WHERE 1 but it doesn't work. Can someone help me? Thanks Hey.. hoping someone can help me on a this issue I have been having for 4 days now. My host has tried to figure out what is causing it and has told me they are finding it very strange, everytime my website is up on their server it will take 600%-800% CPU so they must take it down for fair usage on other customers of course. They said they can easily track and trace websites that are overloading the resources but mine seems too complicated to understand as it is having legitmate traffic (on average 30 users online and 300 visits daily) which would never be the cause of CPU spikes to 600%-800%. They either believe it is a "clever attack" or some PHP script perhaps looping like mad. Anyone help me and my host figure out the problem as we obviously both don't like the website to continue to be offline. The website has very standard content CMS running and clean database it makes no sense to the both of us. Like to mention the last activity I had done on the website was when I tried to insert into database:- Code: [Select] Query failed: errorno=126 error=Incorrect key file for table './teamxcom_webspell/ws_bi2_cup_matches.MYI'; try to repair it query=DELETE FROM ws_bi2_cup_matches WHERE matchno='5' && type='gs' && ladID='0' && 1on1='1' Then after I tried to perform query from database: Code: [Select] Error SQL query: SELECT * FROM `ws_bi2_cup_matches` ORDER BY `ws_bi2_cup_matches`.`matchID` DESC LIMIT 0 , 30 MySQL said: #1030 - Got error 134 from storage engine Then found out the table on phpmyadmin had wrong page numbers in sequence:- 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 379, 746, 1113, --, --, --7349 After I contacted web host they mentioned it is causinga massive problem and took it down after that. Anyone can shed some light on this please? Sorry if it is posted in wrong section! Thanks very much
<!DOCTYPE html> <html> <body> <form action="Practice 1.1.php" method="post"> Catagory Code:<input type="text" name="n" size="2"><br> Units Used <input type="text" name="u" size="2"> <br> <input type="submit" value="Calculate"> </form> <?php $a=$_POST['n']; $b=$_POST['u']; if ($b<=3.75) { echo ""; } ?> </body> </html>
This topic has been moved to Ajax Help. http://www.phpfreaks.com/forums/index.php?topic=327462.0 Hi, I read the HEADER advice on the forum but I think that I still need help to figure out what I am doing wrong with header("location: page_to_load"). In local, the redirection works without problems. When I test online on a free server (p4o.net), it works fine; but when I test it on the paid server (mediaserve.com), the redirect loads a blank page. After the blank page is loaded, I manually load the protected page (MyAccount.php) and all the information were displayed successfuly. I logged out and signed in with wrong credential. The result is a blank page. I manually loaded MyAccount.php again and I had "Access denied". I then concluded that the redirection deos not work. Is there any work arround for this situation? Please help. Thanks Login.php Code: [Select] <form id="login" method="POST" action="handlers/login_handler.php"> <strong>Username</strong> <input name="TextBoxEmailAdress" type="text" id="TextBoxEmailAddress" /> <strong>Password</strong> <input name="TextBoxPassword" type="password" id="TextBoxPassword" /> <input name="ButtonSubmit" value="Login" id="ButtonSubmit" type="submit" /> </form> login_handler.php Code: [Select] <?php ob_start(); //Start session session_start(); //Include database connection details require_once('../includes/WebConfig.php'); //Array to store validation errors $errmsg_arr = array(); //Validation error flag $errflag = false; //Function to sanitize values received from the form. Prevents SQL injection function clean($str) { $str = @trim($str); if(get_magic_quotes_gpc()) { $str = stripslashes($str); } return mysql_real_escape_string($str); } //Sanitize the POST values $Var_EmailAddress = clean($_POST['TextBoxEmailAddress']); $Var_Password1 = clean($_POST['TextBoxPassword']); //Input Validations if($Var_EmailAddress== '') { $errmsg_arr[] = 'Login ID missing'; $errflag = true; } if($Var_Password1== '') { $errmsg_arr[] = 'Password missing'; $errflag = true; } //If there are input validations, redirect back to the login form if($errflag) { $_SESSION['ERRMSG_ARR'] = $errmsg_arr; session_write_close(); header("location: ../index.php?PageId=login"); exit(); } //Create query $Var_Password1 = md5($Var_Password1); $query="SELECT * FROM $tbl_member WHERE EmailAddress='$Var_EmailAddress' AND Password1='$Var_Password1'"; $result=mysql_query($query); //Check whether the query was successful or not if($result) { if(mysql_num_rows($result) == 1) { //Login Successful session_regenerate_id(); $member = mysql_fetch_assoc($result); $_SESSION['SESS_MEMBER_ID'] = $member['Member_Id']; $_SESSION['SESS_FIRST_NAME'] = $member['FirstName']; $_SESSION['SESS_LAST_NAME'] = $member['LastName']; $_SESSION['SESS_EMAIL_ADDRESS'] = $member['EmailAddress']; $_SESSION['SESS_ADMIN_ROLE'] = $member['AdminRole']; $_SESSION['SESS_CONTRIB_EMAIL'] = ""; session_write_close(); header("location: ../MyAccount.php"); exit(); } else { //Login failed header("location: ../index.php?PageId=login-failed"); exit(); } } else { //echo "mysql error: " .mysql_error(); //echo "<br> mysql error number: " .mysql_errno(); //die("Query failed"); //Login failed header("location: ../index.php?PageId=login-failed"); } ?> Hello! I have this approach on form validation(I'm just a newbie) Code: [Select] <?php if(isset($_POST['submit'])) { $proj_name = me_mysql_prep(trim($_POST['proj_name'])); $proj_content = me_mysql_prep($_POST['proj_content']); if(empty($_POST['proj_name'])) { $empty_name = array('Project Name Cannot Be Empty'); } if(empty($_POST['proj_content'])) { $empty_content = array('Content Cannot Be Empty'); } if(isset($empty_name) || isset($empty_content)); { $error_merge = array_merge($empty_name, $empty_content); } if(!empty($error_merge)) { foreach($error_merge as $error) { echo "<span class=\"error_validation\">*". $error . "<br></span>"; } } else { $query = "INSERT into rec_projects (proj_name, content, date_reg) VALUES('{$proj_name}', '{$proj_content}', '{$datenow}')"; $result = mysql_query($query,$connection); } echo "<br><br>"; } ?> My problem is at this line Code: [Select] <?php if(isset($empty_name) || isset($empty_content)); { $error_merge = array_merge($empty_name, $empty_content); } ?> because if, let's say $empty_name is not set, I'm going to have an error like Quote "undefined $empty_name" or something like that. I wonder if there's a PHP function that disregard a value in an array if it's not set.. or you guys have different approach to solve and simplify this?? Im trying to add value into my database and i keep getting the following 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 '','','4','Telegraph (IRE)','3','9-3','','57','Evans, P D','28/1 ','Egan, John '' at line 1" my query looks like this mysqli_query($db,"INSERT INTO `Horses` (`Date`,`Track`,`Runners`, `Going`, `Distance`,`Class`,`Place`,`Losing_Dist`,`Stall`,`Horse`,`Age`,`Weight`,`Headgear`,`Horse_OR`,`Trainer`,`Odds`,`Jockeys_Claim`,`Comments`,`Race_Name` )VALUES ('$date','$place','$norunner','$going','$distance','$class',$place','$distance_bt','$stall','$horse','$age','$weight','$headgear','$OR','$trainer','$odds','$jockey','$comments','$event')")or die(mysqli_error($db));and my table looks like this: Column Type Null Default ID int(255) No Date varchar(250) Yes NULL Track varchar(100) Yes NULL Runners varchar(50) Yes NULL Going varchar(50) Yes NULL Distance varchar(50) Yes NULL Class varchar(50) Yes NULL Place varchar(10) Yes NULL Losing_Dist varchar(50) Yes NULL Stall varchar(250) Yes NULL Horse varchar(50) Yes NULL Age varchar(50) Yes NULL Weight varchar(50) Yes NULL Headgear varchar(50) Yes NULL Horse_OR varchar(50) Yes NULL Trainer varchar(50) Yes NULL Odds varchar(50) Yes NULL Jockeys_Claim varchar(50) Yes NULL Comments varchar(250) Yes NULL Race_Name varchar(250) Yes NULL Since I'm new to programming I still don't know how to solve problems the most efficient way, I'd like to have your advice on this one. This is how I solved it and it works. I have my categories as input buttons (I'm planning to change it into a drop down menu later). Sort by Category: <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <input type='submit' name='All' value='All' /> <input type='submit' name='Smileys' value='Smileys' /> <input type='submit' name='Faces' value='Faces' /> <input type='submit' name='Love' value='Love' /> </form> When the input boxes are clicked the corresponding script below is being run, very simple and to a point primitive, definitely not really efficient, because if you have a lot of categories you'll end up with a lot of code and if you wanted to change one thing you'd have to change it in all the IF BLOCKS. Basically every input button has its own IF BLOCK. <?php if (isset($_POST['All']) OR (!isset($_POST['Smileys']) && !isset($_POST['Faces']) && !isset($_POST['Love']) { // Connect to the database $dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); // Retrieve the score data from MySQL $query = "SELECT * FROM asciiart"; $data = mysqli_query($dbc, $query); // Loop through the array of score data, formatting it as HTML while ($row = mysqli_fetch_array($data)) { echo '<table class="asciiartTable">'; // Display the score data echo '<tr><td class="asciiart_name">'; echo '<strong>' . htmlentities($row['asciiart_name']) . '</strong><br /></td></tr>'; echo '<tr><td class="asciiart_contribution"><pre>' . htmlentities($row['asciiart_contribution']) . '</pre><br /></td></tr>'; echo '<tr><td class="asciiart_categoryDate">' . htmlentities($row['asciiart_category']) . ' | ' . date('M d, Y', strtotime ($row['created_date'])) . ' </td></tr>'; echo '</table>'; } mysqli_close($dbc); } if (isset($_POST['Smileys'])) { // Connect to the database $dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); // Retrieve the chosen category from MySQL $query2 = "SELECT * FROM asciiart WHERE asciiart_category = 'Smileys'"; $data2 = mysqli_query($dbc, $query2); //Loop through the array of data while ($row2 = mysqli_fetch_array($data2)) { echo '<table class="asciiartTable">'; // Display the score data echo '<tr><td class="asciiart_name">'; echo '<strong>' . htmlentities($row2['asciiart_name']) . '</strong><br /></td></tr>'; echo '<tr><td class="asciiart_contribution"><pre>' . htmlentities($row2['asciiart_contribution']) . '</pre><br /></td></tr>'; echo '<tr><td class="asciiart_categoryDate">' . htmlentities($row2['asciiart_category']) . ' | ' . date('M d, Y', strtotime ($row2['created_date'])) . ' </td></tr>'; echo '</table>'; } mysqli_close($dbc); } if (isset($_POST['Faces'])) { // Connect to the database $dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); // Retrieve the chosen category from MySQL $query3 = "SELECT * FROM asciiart WHERE asciiart_category = 'Faces'"; $data3 = mysqli_query($dbc, $query3); //Loop through the array of data while ($row3 = mysqli_fetch_array($data3)) { echo '<table class="asciiartTable">'; // Display the score data echo '<tr><td class="asciiart_name">'; echo '<strong>' . htmlentities($row3['asciiart_name']) . '</strong><br /></td></tr>'; echo '<tr><td class="asciiart_contribution"><pre>' . htmlentities($row3['asciiart_contribution']) . '</pre><br /></td></tr>'; echo '<tr><td class="asciiart_categoryDate">' . htmlentities($row3['asciiart_category']) . ' | ' . date('M d, Y', strtotime ($row3['created_date'])) . ' </td></tr>'; echo '</table>'; } mysqli_close($dbc); } if (isset($_POST['Love'])) { // Connect to the database $dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); // Retrieve the chosen category from MySQL $query4 = "SELECT * FROM asciiart WHERE asciiart_category = 'Love'"; $data4 = mysqli_query($dbc, $query4); //Loop through the array of data while ($row4 = mysqli_fetch_array($data4)) { echo '<table class="asciiartTable">'; // Display the score data echo '<tr><td class="asciiart_name">'; echo '<strong>' . htmlentities($row4['asciiart_name']) . '</strong><br /></td></tr>'; echo '<tr><td class="asciiart_contribution"><pre>' . htmlentities($row4['asciiart_contribution']) . '</pre><br /></td></tr>'; echo '<tr><td class="asciiart_categoryDate">' . htmlentities($row4['asciiart_category']) . ' | ' . date('M d, Y', strtotime ($row4['created_date'])) . ' </td></tr>'; echo '</table>'; } mysqli_close($dbc); } My question is: is there a way to have just one block of script and the script automatically inserts the right INPUT BUTTON into the query in the script? Something similar to this, even though it doesn't work I'm just showing it for showcase purposes: if (isset($_POST['Smileys']) || (isset($_POST['Faces']) || (isset($_POST['Love'])) { // Connect to the database $dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); // Retrieve the chosen category from MySQL $query2 = "SELECT * FROM asciiart WHERE asciiart_category = 'Smileys' || 'Faces' || 'Love'"; $data2 = mysqli_query($dbc, $query2); Notice in the query, it is looking for THAT keyword that has been PRESSED on the INPUT BUTTON. How would I be able to create a logic like this so I can create a whole chain of categories? Thanks for advice. How do I display the actual errors in IIS 7.5? If I miss a semicolon, I get: "HTTP Error 500.0 - Internal Server Error" absolutely useless. In prior versions, I could see the line and get to the PHP error. How do I display PHP errors? I've added: set_ini('display_errors', '1'); but it doesn't help. |