PHP - Mysql Having Errors Help Please.
Im trying to make a login box for my website and i have a problem here it is:
I put all my info in the file. Code: [Select] <?php $host = "localhost"; $user = "scape4le"; <--- thats my username $pass = "********";<--- my pass covered it out $db = "scape4le_members";<------ My DATABASE. ?> Is there any problem with the code? When i put it on my website i get this error. Code: [Select] Warning: mysql_connect() [function.mysql-connect]: Unknown MySQL server host 'DB_HOST' (1) in /home/scape4le/public_html/Login/login-exec.php on line 15 Failed to connect to server: Unknown MySQL server host 'DB_HOST' (1) Theres more codes for the whole login box but too much. But thats the file were the problems at. Here is the code that it says it has a error in Login-exec.php Code: [Select] <?php //Start session session_start(); //Include database connection details require_once('config.php'); //Array to store validation errors $errmsg_arr = array(); //Validation error flag $errflag = false; //Connect to mysql server $link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); if(!$link) { die('Failed to connect to server: ' . mysql_error()); } //Select database $db = mysql_select_db(DB_DATABASE); if(!$db) { die("Unable to select database"); } //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 $login = clean($_POST['login']); $password = clean($_POST['password']); //Input Validations if($login == '') { $errmsg_arr[] = 'Login ID missing'; $errflag = true; } if($password == '') { $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: login-form.php"); exit(); } //Create query $qry="SELECT * FROM members WHERE login='$login' AND passwd='".md5($_POST['password'])."'"; $result=mysql_query($qry); //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_write_close(); header("location: member-index.php"); exit(); }else { //Login failed header("location: login-failed.php"); exit(); } }else { die("Query failed"); } ?> If anyone could help i would appreciate that, Thanks Similar TutorialsThis topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=321772.0 I have a problem where I am getting these errors after a form has been submitted from join.html Here are the errors: Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user 'scswccla'@'localhost' (using password: NO) in /home/scswccla/public_html/insert.php on line 9 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in /home/scswccla/public_html/insert.php on line 9 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user 'scswccla'@'localhost' (using password: NO) in /home/scswccla/public_html/insert.php on line 9 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in /home/scswccla/public_html/insert.php on line 9 Here is the insert.php file http://pastebin.com/EVtgidQC And the join.html file - http://pastebin.com/hqDtGLe5 How would I fix those errors - I got the code from http://forum.hey0.net/showthread.php?tid=2509 The form is at scswc.com/join.html if you want to look at it. I really want to get this working so if you need any more info to help fix it just ask thanks! 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 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> 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"; ?> 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. 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! 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 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 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."; 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"/> 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. The bit of code I'm using it on is: if((@include("languages/".LANGUAGE.".php")) != 1) { require("languages/".DEFAULT_LANG.".php"); } But the error is still be produced. I'm using a custom error handler, is there anyway to include the @ in the custom error handler? I am writing a script, but keep getting a 500 error page. I've tried various tricks to isolate the problem to no avail. My old system would always send me an email to report the error, but since my new box, it isn't working The major change from my old setup is that I am now using fast CGI I rememeber that there is a log that records errors but I havn't been able to find it if there is one... Or I am looking in the wrong places. Can anyone nudge me in the right direction on this? Thanks, David No matter what I try, I keep getting a session error. Can somebody look at this code and see what the problem? Code: [Select] <?php ob_start(); session_start(); ini_set("display_errors",'ON'); require_once('../lib/config.db.php'); require_once('../inc/auth_func.php'); $message = ''; //echo DECRYPT('w9Ti2cqStdDU2w=='); if (!empty($_POST)) { $post = array(); foreach ($_POST as $key => $value) { $post[$key] = mysql_real_escape_string(strip_tags(html_entity_decode($value))); } $username = $post['username']; $password = ENCRYPT($post['password']); $sql = sprintf("SELECT id, name,transactionid FROM app_logins WHERE username = '%s' AND password = '%s' AND active = 1", $username, $password); $result = mysql_query($sql) or trigger_error(mysql_error()); if ($result && mysql_num_rows($result) > 0) { $row = mysql_fetch_object($result); $sqlapp = "SELECT * FROM app_queue WHERE transactionid={$row->transactionid} ORDER BY appid ASC LIMIT 1"; $rsapp = mysql_query($sqlapp); if($rsapp && mysql_num_rows($rsapp) > 0){ $rowapp = mysql_fetch_object($rsapp); $_SESSION['default_appid'] = $rowapp->appid; } $_SESSION['app_login_id'] = $row->id; $_SESSION['login_name'] = $row->name; $_SESSION['tid'] = $row->transactionid; $location = !empty($post['from']) ? urldecode($post['from']) : 'index.php'; //ob_clean(); header("location:{$location}"); } else { $message = '<p style="color:red;">That username and password<br />combination match none of our logins</p>'; } } ?> Thank you in advance And I fixed literally probably over couple hundrend by now, But i got like 200 more I need to fix, but is there a way so I can set a SETTINGS IN PHP.INI to make the error's come out by Lowest to highest LINE? Cuz I get error in filename.php on LINE 50 then I fix it, then the last error is like LINE 1 or line 2500..... so I have to scroll all the way up again, it get's annoying is there a way to order the error's so it's easy lowest line to highest line? Cuz I got so many to fix :O Ternary operator has been my best friend lately! I'm not sure why but I'm getting the following errors inside of FireBug after my form submits. <b>Warning</b>: Invalid argument supplied for foreach() in <b>/home/xtremer/public_html/efedmanager/processes/bookings.php</b> on line <b>49</b><br /> <br /> <b>Warning</b>: Invalid argument supplied for foreach() in <b>/home/xtremer/public_html/efedmanager/processes/bookings.php</b> on line <b>68</b><br /> <br /> <b>Warning</b>: Invalid argument supplied for foreach() in <b>/home/xtremer/public_html/efedmanager/processes/bookings.php</b> on line <b>82</b><br /> Code: [Select] <?php error_reporting( E_ALL ); // Include the database page require ('../inc/dbconfig.php'); $eventItems = json_decode( $_POST[ 'event_items' ], true ); $event_id = (int)$_POST['event_id']; for( $i = 0; $i < sizeof( $eventItems ); $i++ ) { $eventItem = $eventItems[ $i ]; $segment_type = $eventItem['segment_type']; if ($eventItem[ 'segment_type' ] === 'Introduction' ) { $introduction_preview = $eventItem['introduction_preview']; $query = "INSERT INTO `event_segments` (event_id, segment_type, introduction_preview) VALUES ('".$event_id."', '".$segment_type."','".$introduction_preview."')"; mysqli_query($dbc, $query); } if ($eventItem[ 'segment_type' ] == "Match") { $segment_writer_id = $eventItem['segment_writer_id']; $match_number = $eventItem['match_number']; $match_type_id = $eventItem['match_type_id']; $segment_title = $eventItem['segment_title']; $titles_id_list = $eventItem['titles_id_list']; $stipulations_id_list = $eventItem['stipulations_id_list']; $characters_id_list = $eventItem['characters_id_list']; $segment_preview = $eventItem['segment_preview']; $query = "INSERT INTO `event_segments` (event_id, segment_writer_id, segment_type, match_number, segment_title, segment_preview, is_submitted_yes_or_no_id) VALUES ('".$event_id."', '".$segment_writer_id."', '".$segment_type."' ,'".$match_number."','".$segment_title."','".$segment_preview."',2)"; mysqli_query($dbc, $query); $event_segment_id = mysqli_insert_id($dbc); foreach ($characters_id_list AS $character_id) { $query2 = "INSERT INTO `event_match_characters` (event_segment_id, character_id) VALUES ('".$event_segment_id."', '".$character_id."')"; } mysqli_query($dbc, $query); $query = "INSERT `event_match_match_types` (event_segment_id, match_type_id) VALUES ('".$event_segment_id."', '".$match_type_id."')"; mysqli_query($dbc, $query); if ($stipulations_id_list != "0") { foreach ($stipulations_id_list AS $stipulation_id) { $query = "INSERT `event_match_stipulations` (event_segment_id, match_type_id) VALUES ('".$event_segment_id."', '".$stipulation_id."')"; mysqli_query($dbc, $query); } } if ($titles_id_list != "0") { foreach ($titles_id_list AS $title_id) { $query = "INSERT `event_match_titles` (event_segment_id, title_id) VALUES ('".$event_segment_id."', '".$title_id."')"; mysqli_query($dbc, $query); } } } if ($eventItem[ 'segment_type' ] == "Segment") { $segment_writer_id = $eventItem['segment_writer_id']; $segment_number = $eventItem['segment_number']; $query = "INSERT INTO `event_segments` (event_id, segment_writer_id, segment_type, segment_number, sort_order_preview, is_submitted_yes_or_no_id) VALUES ('".$event_id."', '".$segment_writer_id."', '".$segment_type."' ,'".$segment_number."','".$sort_order_number."',2)"; mysqli_query($dbc, $query); } if ($eventItem[ 'segment_type' ] == "Conclusion") { $conclusion_preview = $eventItem['conclusion_preview']; $query = "INSERT INTO `event_segments` (event_id, segment_type, conclusion_preview) VALUES ('".$event_id."', '".$segment_type."','".$conclusion_preview."')"; mysqli_query($dbc, $query); } $query = "UPDATE `events` SET `event_status_id` = 2 WHERE id = '".$event_id."' LIMIT 1"; mysqli_query($dbc, $query); } ?> I have the following error and i'm not too sure what the problem is. Warning: ini_set() has been disabled for security reasons in /index.php on line 62 Warning: require() [function.require]: Unable to access /core/Bootstrap.php in /index.php on line 106 Warning: require(/core/Bootstrap.php) [function.require]: failed to open stream: No such file or directory in /index.php on line 106 Fatal error: require() [function.require]: Failed opening required '/core/Bootstrap.php' (include_path='.:/usr/lib/php') in /index.php on line 106 any help would be much appreciated |