PHP - Errors In Php Coding
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 Similar Tutorialshey 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'"); } ?> 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> Hi 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 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> 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. i get this when i tried to retrive a venue id so admin can edit them Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource Warning: session_start() [FUNCTION.SESSION-START]: Cannot send session cache limiter - headers already sent Code: [Select] <?php include 'scripts/connect.php'; if(isset($_GET['vid'])){ $query = mysql_query("SELECT * FORM venue"); while ($row = mysql_fetch_array($query)){ $id = $row['id']; $venuename = $row['venuename']; $address = $row['address']; $phone = $row['phone']; $vemail = $row['vemail']; $state = $row['state']; $town = $row['town']; $zip = $row['zip']; $seats = $row['seats']; } } ?> <?php require "header.php"; ?> Hi I'm in need of help with some errors that the admin page of my cms is spitting out, I'm very new to php but I'm great understanding directions so any help that anyone can provide will be greatly appreciated.
These are the errors being displayed:
Warning: date() [function.date]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/Chicago' for 'CDT/-5.0/DST' instead in /home/mysite/public_html/includes/joomla.php on line 437 Does anyone know what would cause this error: Notice: Undefined index: file in C:\Inetpub\wwwroot\Upload\uploader3.php on line 2 No file specified with these files for uploading images: uploader.htm <html><head><title>File Uploader</title></head> <body><h3>File Upload</h3> Select a file to upload:<br> <form action="uploader.php" method="post" enctype="multipart/form-data"> <input type="file" name="file" size="45"> <br> <input type="submit" value="Upload File"> </form> </body></html> and, uploader.php <?php if( $_FILES['file']['name'] != "" ) { copy ( $_FILES['file']['tmp_name'], "C:/Inetpub/wwwroot/Upload/" . $_FILES['file']['name'] ) or die( "Could not copy file" ); } else{ die( "No file specified" ); } ?> <html> <head><title>Upload Complete</title></head> <body> <h3>File Upload Succeeded...</h3> <ul> <li>Sent: <?php echo $_FILES['file']['name']; ?> <li>Size: <?php echo $_FILES['file']['size']; ?> bytes <li>Type: <?php echo $_FILES['file']['type']; ?> </ul> <a href="<?php echo "C:/Inetpub/wwwroot/Upload/".$_FILES['file']['name']; ?>"><img src="<?php echo "C:/Inetpub/wwwroot/Upload/".$_FILES['file']['name']; ?>" height="200"></a> </body> </html> Thanks! Hello. I am at beginning with php and now trying to make an ecommerce website. I know it's a bit stupid but it works until now. This site work perfect on localhost using xampp but then I transfered it to webhost, I get a lot of errors. i m facing this 2 errors in the below script
Notice: Undefined index: media in D:\server\website\htdocs\wefondyou\themes\grape\layout\story\content.phtml on line 107 Warning: Invalid argument supplied for foreach() in D:\server\website\htdocs\wefondyou\themes\grape\layout\story\content.phtml on line 107 I had tried add isset and is_array to line, the errors gone away, but image also gone away. any ideas?? <div id="story_<?php echo $sk['story']['id']; ?>" class="story-wrapper story_<?php echo $sk['story']['id']; ?>" data-story-id="<?php echo $sk['story']['id']; ?>"> <div class="publisher-wrapper"> <table border="0" width="100%" cellspacing="0" cellpadding="0"> <tr> <td width="48px" align="left" valign="top"> <a href="<?php echo $sk['story']['publisher']['url']; ?>" data-href="?tab1=timeline&id=<?php echo $sk['story']['publisher']['username']; ?>"> <img class="avatar" src="<?php echo $sk['story']['publisher']['thumbnail_url']; ?>" width="40px" height="40px" alt="<?php echo $sk['story']['publisher']['name']; ?>"> </a> </td> <td align="left" valign="top"> <a class="name" href="<?php echo $sk['story']['publisher']['url']; ?>" data-href="?tab1=timeline&id=<?php echo $sk['story']['publisher']['username']; ?>"> <?php echo substr($sk['story']['publisher']['name'], 0, 35); ?> </a> <?php if ($sk['story']['recipient_exists'] == true) { ?> <i class="icon-arrow-right recipient-indicator-icon"></i> <a class="name" href="<?php echo $sk['story']['recipient']['url']; ?>" data-href="?tab1=timeline&id=<?php echo $sk['story']['recipient']['username']; ?>"> <?php echo substr($sk['story']['recipient']['name'], 0, 35); ?> </a> <?php } echo $sk['story']['activity_text']; ?> <div class="other-data"> <span class="time-wrapper ajax-time" title="<?php echo date('c', $sk['story']['time']); ?>"> <?php echo date('c', $sk['story']['time']); ?> </span> <?php if ($sk['story']['location_exists'] == true) { ?> <abbr class="space3">·</abbr> <span class="location-wrapper" title="<?php echo $sk['story']['location']['name']; ?>"> <i class="icon-map-marker"></i> <?php echo $sk['story']['location']['name']; ?> </span> <?php } ?> </div> </td> </tr> </table> <?php if ($sk['logged'] == true) { ?> <div class="setting-buttons"> <?php if ($sk['story']['admin'] == true) { ?> <span class="remove-btn cursor-hand" title="<?php echo $lang['remove']; ?>" onclick="SK_deletePostWindow(<?php echo $sk['story']['id']; ?>);"> <i class="icon-remove progress-icon"></i> </span> <?php } elseif (!SK_isPostReported($sk['story']['id'])) { ?> <span class="report-btn cursor-hand" title="<?php echo $lang['report']; ?>" onclick="SK_reportPost(<?php echo $sk['story']['id']; ?>);"> <i class="icon-flag progress-icon"></i> </span> <?php } ?> </div> <?php } ?> </div> <?php if ($sk['logged'] == true) { ?> <div class="options-wrapper"> <?php echo SK_getPostLikeButton($sk['story']['id']); ?> <abbr class="space6">·</abbr> <?php echo SK_getPostShareButton($sk['story']['id']); ?> <abbr class="space6">·</abbr> <?php echo SK_getPostFollowButton($sk['story']['id']); ?> </div> <?php } if (!empty($sk['story']['text'])) { ?> <div class="text-wrapper"> <?php echo $sk['story']['text']; ?> </div> <?php } if ($sk['story']['media_exists'] == true) { // If it is photos if ($sk['story']['media_type'] == "photos") { ?> <div class="photos-wrapper"> <?php $photo_class = 'width-' . $sk['story']['media_num']; if ($sk['story']['media_num'] >= 3) { $photo_class = 'width-3'; } LINE HERE 107 -----> foreach ($sk['story']['media'] as $photo) { ?> <a href="javascript:void(0);"> <img class="<?php echo $photo_class; ?>" src="<?php echo $photo['url']; ?>" alt="Photo" onclick="javascript:SK_openLightbox(<?php echo $photo['post_id']; ?>);"> </a> <?php } ?> </div> <?php } elseif ($sk['story']['media_type'] == "soundcloud") { ?> <div class="soundcloud-wrapper" align="center"> <iframe frameborder="0" src="https://w.soundcloud.com/player/?url=<?php echo $sk['story']['media']['url']; ?>&color=f07b22" width="100%"></iframe> </div> <?php } elseif ($sk['story']['media_type'] == "youtube") { ?> <div class="youtube-wrapper" align="center"> <iframe src="https://www.youtube.com/embed/<?php echo $sk['story']['media']['id']; ?>?ap=%2526fmt%3D18&disablekb=1&rel=0" width="100%" height="300px" frameborder="0" allowfullscreen></iframe> </div> <?php } } elseif ($sk['story']['location_exists'] == true) { ?> <div class="google-map-viewer-wrapper" align="center"> <img src="http://maps.googleapis.com/maps/api/staticmap?center=<?php echo $sk['story']['location']['name']; ?>&zoom=13&size=600x300&maptype=roadmap&markers=color:red%7C<?php echo $sk['story']['location']['name']; ?>" width="100%" alt="<?php echo $sk['story']['location']['name']; ?>"> </div> <?php } ?> <div class="activity-wrapper"> <table border="0" width="100%" cellspacing="0" cellpadding="0"> <tr> <td align="left" valign="middle"> <span class="story-like-activity"> <?php echo SK_getPostLikeActivityButton($sk['story']['id']); ?> </span> <abbr class="space6">·</abbr> <span class="story-comment-activity"> <?php echo SK_getPostCommentActivityButton($sk['story']['id']); ?> </span> <abbr class="space6">·</abbr> <span class="story-share-activity"> <?php echo SK_getPostShareActivityButton($sk['story']['id']); ?> </span> </td> <td align="right" valign="middle"> <?php if ($sk['story']['via_type'] == "like") { ?> <a class="via-name" href="<?php echo $sk['story']['via']['url']; ?>" data-href="?tab1=timeline&id=<?php echo $sk['story']['via']['username']; ?>"> <?php echo $sk['story']['via']['name']; ?> </a> <?php echo $lang['likes_this_label']; ?> <?php } elseif ($sk['story']['via_type'] == "share") { ?> <a class="via-name" href="<?php echo $sk['story']['via']['url']; ?>" data-href="?tab1=timeline&id=<?php echo $sk['story']['via']['username']; ?>"> <?php echo $sk['story']['via']['name']; ?> </a> <?php echo $lang['shared_this_label']; ?> <?php } elseif ($sk['story']['via_type'] == "tag") { ?> <a class="via-name" href="<?php echo $sk['story']['via']['url']; ?>" data-href="?tab1=timeline&id=<?php echo $sk['story']['via']['username']; ?>"> <?php echo substr($sk['story']['via']['name'], 0, 15); ?> </a> <?php echo $lang['tagged_on_this_label']; ?> <?php } ?> </td> </tr> </table> </div> <div class="comments-container hidden"> <?php if ($sk['story']['view_all_comments'] == true) { ?> <div class="view-more-wrapper" align="center" onclick="SK_loadAllComments(<?php echo $sk['story']['id']; ?>);"> <i class="icon-lightbulb progress-icon hide"></i> <?php echo $lang['view_all_comments_label']; ?> </div> <?php } ?> <div class="comments-wrapper"> <?php echo $sk['story']['comments']; ?> </div> <?php echo $sk['story']['comment']['publisher_box']; ?> </div> </div> When I am trying to update a record in the database i get this error after I submit the form that is populated from the database. 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 'desc = 'SFR ANNOUNCES 3RD ANNUAL \"12 DAYS OF CHRISTMAS FOOD DRIVE\"', body = '<' at line 1 im getting following errors:
Warning: DOMDocument::load() [domdocument.load]: Opening and ending tag mismatch: property line 6 and xsl:for-each in /home/students/accounts/s4909321/cos80021/www/htdocs/Assignment3/apartment.xsl, line: 25 in/home/students/accounts/s4909321/cos80021/www/htdocs/Assignment3/transform1.php on line 9 Warning: DOMDocument::load() [domdocument.load]: Opening and ending tag mismatch: for-each line 5 and property in /home/students/accounts/s4909321/cos80021/www/htdocs/Assignment3/apartment.xsl, line: 26 in/home/students/accounts/s4909321/cos80021/www/htdocs/Assignment3/transform1.php on line 9 Warning: XSLTProcessor::importStylesheet() [xsltprocessor.importstylesheet]: compilation error in /home/students/accounts/s4909321/cos80021/www/htdocs/Assignment3/transform1.php on line 14 Warning: XSLTProcessor::importStylesheet() [xsltprocessor.importstylesheet]: xsltParseStylesheetProcess : empty stylesheet in /home/students/accounts/s4909321/cos80021/www/htdocs/Assignment3/transform1.php on line 14 Warning: XSLTProcessor::transformToXml() [xsltprocessor.transformtoxml]: No stylesheet associated to this object in /home/students/accounts/s4909321/cos80021/www/htdocs/Assignment3/transform1.php on line 16 Fatal error: Call to a member function saveXML() on a non-object in /home/students/accounts/s4909321/cos80021/www/htdocs/Assignment3/transform1.php on line 18 the xslt file is as following: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/19...XSL/Transform"> <xsl:output method="xml" indent="yes"/> Does anyone know of a function that I can use to get all occurring PHP errors during script execution into a string. Also, does anyone know what's wrong with php.net? It keeps saying service is down. The code below returns the correct results, which are in this case are email addresses. After each displayed value there is a br eg. emai1@hotmail.com<br>email2@hotmail.com<br>email3@ etc. So the quesion is, can i change the below codeing to prevent this. I have tried changing $message .= "<br>". $row['email'] to $message .= "\n". $row['email'] but this results in; Warning: mail() [function.mail]: SMTP server response: 451 See http://pobox.com/~djb/docs/smtplf.html $code = $_GET['postcode']; $message = $_GET['message']; $emailad = "email@hotmail.co.uk"; $shortcode = substr($code,0,2); $result = mysql_query("SELECT email FROM treesurgeons WHERE postcode like '%" . $shortcode . "%' ORDER BY companyName LIMIT 3") or die(mysql_error()); echo "<h2>Business Names:</h2>"; while ($row = mysql_fetch_array( $result )) { $message .= "<br>". $row['email'] ; } echo "\n"; echo $message; mail( "$emailad", "Header","$message" ); echo "<br>" . "Thank you for using our mail form."; Whats the best way to handle database errors. I been using ob_start() stuff to run the code and if a database connection error occurs an variable $error turns to 1 and it displays the error code instead of the normal page that should be displayed when no errors occur. It works but I want to know if there is any better way to manage a db connection error while running a script. Also, how do you manage a problem when like 3 queries are ran to setup a new user account and the last one fails because the db connection drops or something, how would you go about handling a 2/3 query successful? I'm really stuck on how to manage errors if a db connection fails after the first connection is successful. I apologize to keep posting this in different topics, but since I can't edit my last topic to fit this one; I must. Code: (function.php) [Select] <?php error_reporting(-1); ini_set('display_errors', 1); function check() { $admin="test"; $pass="test"; if (isset($_POST["user"]) && $_POST["user"] == $admin && isset($_POST["pwd"]) && $_POST["pwd"] == $pass) { sesshin(); } } function sesshin() { session_start(); $_SESSION['user'] = "test"; if ($_SESSION['user'] = "test") { header('Location: output.php'); } else { header('Location: index.html'); } } ?> I get the following errors when I try to login. Code: [Select] Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /srv/www/deadnode.com/public_html/function.php:25) in /srv/www/deadnode.com/public_html/function.php on line 15 Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /srv/www/deadnode.com/public_html/function.php:25) in /srv/www/deadnode.com/public_html/function.php on line 15 Warning: Cannot modify header information - headers already sent by (output started at /srv/www/deadnode.com/public_html/function.php:25) in /srv/www/deadnode.com/public_html/function.php on line 1 I've just confused myself into doing this. Maybe I can do all of this in one function? Check(), should look to see if the form information is correct. If so, then it should start the session and proceed to the output.php page. The other thing I'm trying to figure out is how to block public view of output.php if you havent logged in. Quote Notice: Use of undefined constant d - assumed 'd' in /home/rayth/public_html/forum/shout.php on line 11 Strict Standards: date() [function.date]: It is not safe to rely on the system's timezone settings. Please use the date.timezone setting, the TZ environment variable or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'UTC' for 'UTC/0.0/no DST' instead in /home/rayth/public_html/forum/shout.php on line 11 Notice: Use of undefined constant F - assumed 'F' in /home/rayth/public_html/forum/shout.php on line 11 Strict Standards: date() [function.date]: It is not safe to rely on the system's timezone settings. Please use the date.timezone setting, the TZ environment variable or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'UTC' for 'UTC/0.0/no DST' instead in /home/rayth/public_html/forum/shout.php on line 11 Notice: Use of undefined constant Y - assumed 'Y' in /home/rayth/public_html/forum/shout.php on line 11 Strict Standards: date() [function.date]: It is not safe to rely on the system's timezone settings. Please use the date.timezone setting, the TZ environment variable or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'UTC' for 'UTC/0.0/no DST' instead in /home/rayth/public_html/forum/shout.php on line 11 I keep getting this. Line 11: $Date = date(d)." ".date(F)." ".date(Y); Hi. I was just wondering if it is possible to write custom mysql errors. I have hunted around for some but cant find any. Currently I write my errors like... or die (mysql_error()); How ever I see this as a problem! As Im not the best coder there are bound to be errors in my code. I dont want somebody who knows what they are doing to cause an error and then doing it (mysql_error()) will point them in the right direction to what I have missed. I would rather have my own error saying what line the issue is with. I have tried..... or die (mysql_error(My personal error here)) However this does not work. Please help. Thank you I get this 2 errors everytime i hit "Sign Up" in my registration form i'm creating for my new website: Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in [php file location] on line 64 Deprecated: Function eregi() is deprecated in [php file location] on line 87 I have created a database in, MySQL with phpMyAdmin, named "membership" and a table named "users" with these fields: Field Type Collation Attributes Null Default Extra username varchar(20) latin1_swedish_ci No None first_name varchar(30) latin1_swedish_ci No None last_name varchar(30) latin1_swedish_ci No None password varchar(30) latin1_swedish_ci No None email varchar(50) latin1_swedish_ci No None gender text latin1_swedish_ci No None birth_day date No None This is the 2 parts of the php code where i get the 2 errors: public function user_exists() { mysql_connect("localhost","root","101Dalmatiner") or die(mysql_error()); mysql_select_db("membership") or die (mysql_error()); $data = mysql_query("SELECT ID FROM users WHERE username = '{$this->username}'"); return mysql_num_rows($data) > 0 ? 1 : 0; <---- the line where the first error appears } if(empty($this->email) || !eregi('^[a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+\.[a-zA-Z]{2,4}$',$this->email)) $this->errors[] = 'Invalid Email'; There is all the neccesary informationg you'll need if your willing to look through it all and help my i think! I'm kinda new to php and MySQL so don't blame me if the code is messed up or something look really wrong, i'd appreciate any help i can get on this! |