SCRIPT438:对象不支持"handleError"属性或方法,文件上传功能 20C

写了一个文件上传功能,本地运行没问题,放在服务器上就报错,希望有大神能告诉下原因。本地是ie9的,服务器上是ie8图片说明

1.前端代码:图片说明
图片说明
图片说明
2.后台代码:图片说明

1个回答

建议你升级服务器IE版本。IE8的兼容性较IE9都差很多,更别提和现在的IE11了。你用的第三方JQUERY包,里面封装的一些函数IE8下可能出现无法解析的情况。

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
mkdir():许可Laravel

<div class="post-text" itemprop="text"> <p>I'm running the following script for an image upload in a server and getting the following error while it works perfectly on the localhost. </p> <p><strong>Code</strong></p> <pre><code>$user_id = Auth::id(); $logicpath = 'userdp/' . $user_id . '/'; $pubpath = 'userdp/' . $user_id . '/' . $dpFile; $path = '/userdp/' . $user_id . '/' . $dpFile; if (!file_exists($logicpath)) { mkdir($logicpath, 0777, true); } </code></pre> <p><strong>Error</strong></p> <blockquote> <p>ErrorException in UploadController.php line 605: mkdir(): Permission denied</p> <p>at HandleExceptions-&gt;handleError('2', 'mkdir(): Permission denied', '/var/www/html/laravel/app/Http/Controllers/UploadController.php', '605', array('dp' =&gt; object(UploadedFile), 'ext' =&gt; 'jpg', 'img' =&gt; object(Image), 'mime' =&gt; 'image/jpeg', 'width' =&gt; '200', 'height' =&gt; '200', 'fileSize' =&gt; '17152', 'dpFile' =&gt; 'f12f298ab18d58a59c4ed8a589cd1cdc.jpg', 'user_id' =&gt; '1', 'logicpath' =&gt; 'userdp/1/', 'pubpath' =&gt; 'userdp/1/f12f298ab18d58a59c4ed8a589cd1cdc.jpg', 'path' =&gt; '/userdp/1/f12f298ab18d58a59c4ed8a589cd1cdc.jpg'))</p> </blockquote> <p>I tried <code>chmod 777 public</code> and restarted the server. But it didn't work. </p> </div>

网页里的一段超级复杂的javascript代码,不知道做什么用的,问了几个高手都无法解答

第一段: <script type="text/javascript"> /*<![CDATA[*/ var DataBrainConfig = {'SiteId':'5960','ConfigurationId':'1','AutoIntegration':true,'checkTimeMeter':1,'useDMP':true,'timeRequestLimit':500,'dmpPartnerKey':'6SysO2MEZq69sDxIvJm58g2','customAttributes':[{'Name':'vertical','Value':'dating'}]};var data_brain = false; var JSON; if (!JSON) { JSON = {}; } if (typeof JSON.stringify !== 'function') { JSON.stringify = function (value, replacer, space) { var i; gap = ''; indent = ''; if (typeof space === 'number') { for (i = 0; i < space; i += 1) { indent += ' '; } } else if (typeof space === 'string') { indent = space; } rep = replacer; if (replacer && typeof replacer !== 'function' && (typeof replacer !== 'object' || typeof replacer.length !== 'number')) { throw new Error('JSON.stringify'); } return str('', { '': value }); }; } /** * * @constructor */ function DataBrain() { this.TrackerUrl = 'http://tracker.databrain.com'; this.AT_LOADPAGE = 1; this.siteid = 0; this.cfid = 0; this.at = 0; this.vid = 0; this.checkTimeMeter = 0; this.startTime = 0; this.startResponseTime = 0; this.endTime = 0; this.trackError = 0; this.RequestStatuses = ['start', 'progress', 'finished', 'error']; this.requestStatus = this.RequestStatuses[0]; this.methods = ['ajax', 'script']; this.method = this.methods[1]; this.ap = {}; this.timeRequestLimit = 300; this.useDMP = false; this.mergeData = {}; this.dmpPartnerKey = ''; this.ca = []; this.init(); } /** * init */ DataBrain.prototype.init = function() { this.getVid(); this.setParam(); if ( 0 != this.checkTimeMeter) { this.startTrackMeter(); } this.trackDataBrain(); }; /** * Start Track Meter */ DataBrain.prototype.startTrackMeter = function() { this.startTime = new Date().getTime(); }; /** * Start Track Response Meter */ DataBrain.prototype.startReponseMeter = function() { this.startResponseTime = new Date().getTime(); }; /** * End Track Meter */ DataBrain.prototype.endTrackMeter = function() { this.endTime = new Date().getTime(); }; /** * End Track Meter */ DataBrain.prototype.getTrackMeterTime = function() { var timeDiff = this.endTime - this.startTime; return timeDiff; }; DataBrain.prototype.getCurrentMeterTime = function() { return new Date().getTime() - this.startResponseTime; } /** * Get Vid */ DataBrain.prototype.getVid = function() { this.vid = document.cookie.substr(document.cookie.indexOf('vid=')+4, 36); }; /** * * @param cookieName * @param cookieValue * @param nDays * @constructor */ DataBrain.prototype.SetCookie = function(cookieName,cookieValue,nDays) { var today = new Date(); var expire = new Date(); if (nDays==null || nDays==0) nDays=1; expire.setTime(today.getTime() + 3600000*24*nDays); document.cookie = cookieName+'='+escape(cookieValue) + ';expires='+expire.toGMTString() + ';path=/'; }; /** * Set Vid To Cookie */ DataBrain.prototype.setVid = function(vid) { this.SetCookie('vid', vid, 365); }; /** * Check Vid * @returns {boolean} */ DataBrain.prototype.isSettedVid = function() { var result = false; if ( 0 < parseInt(this.vid) ) { result = true; } return result; }; /** * Set Parameters to track action in DataBrain */ DataBrain.prototype.setParam = function() { this.siteid = DataBrainConfig.SiteId; this.cfid = parseInt(DataBrainConfig.ConfigurationId); this.at = parseInt(DataBrainConfig.AutoIntegration); this.checkTimeMeter = parseInt(DataBrainConfig.checkTimeMeter); this.ap = this.getActionParam(); this.ca = DataBrainConfig.customAttributes; this.useDMP = DataBrainConfig.useDMP; this.timeRequestLimit = parseInt(DataBrainConfig.timeRequestLimit); this.dmpPartnerKey = DataBrainConfig.dmpPartnerKey; }; /** * Return parameters of page to Action * @returns {{Content: string, Referrer: string, Title: string}} */ DataBrain.prototype.getActionParam = function() { var _location = document.location.href.substring(0, 300); var _referrer = document.referrer.substring(0, 300); var _title = document.title.substring(0, 300); return { Content: _location, Referrer: _referrer, Title: _title }; }; /** * init request to trackDataBrain */ DataBrain.prototype.trackDataBrain = function() { if ( this.methods[1] == this.method ) { this.scriptDataBrain(); } else { this.requestToDataBrain(); } }; /** * Prepare Data to send request * @returns {string} */ DataBrain.prototype.prepareData = function() { var params = 'siteid=' + this.siteid + '&cfid=' + this.cfid + '&at=' + this.AT_LOADPAGE; if (this.useDMP != true) { params = '/track.ashx?' + params; } else { params = '/bridge.ashx?' + params + '&partnerKey=' + this.dmpPartnerKey; } params += (this.ap == {} ? '' : '&ap=' + escape(JSON.stringify(this.ap))); params += (this.ca ? '&ca=' + escape(JSON.stringify(this.ca)) : ''); return params; }; /** * Prepare Data to send request * @returns {string} */ DataBrain.prototype.prepareDataScript = function() { var params = 'siteid=' + this.siteid + '&cfid=' + this.cfid + '&at=' + this.AT_LOADPAGE; if (this.useDMP != true) { params = '/track.ashx?' + params; } else { params = '/bridge.ashx?' + params + '&partnerKey=' + this.dmpPartnerKey; } params += (this.ap == {} ? '' : '&ap=' + encodeURIComponent(JSON.stringify(this.ap))); params += (this.ca ? '&ca=' + encodeURIComponent(JSON.stringify(this.ca)) : ''); return params; }; /** * Send request */ DataBrain.prototype.requestToDataBrain = function() { var req = new XMLHttpRequest(); var body = ''; var self = this; this.requestStatus = this.RequestStatuses[1]; if ('withCredentials' in req) { self.startReponseMeter(); req.open('GET', this.TrackerUrl + this.prepareData(), true); req.onreadystatechange = function() { if (req.readyState === 4) { if (req.status >= 200 && req.status < 400) { var res = req.responseText; if (self.useDMP == true) { self.handleResponseDMP(self, res); } else { self.handleResponse(self, res); } } else { self.handleError(self); } } }; req.send(body); } }; /** * Request script */ DataBrain.prototype.scriptDataBrain = function() { var req = new XMLHttpRequest(); var body = ''; var self = this; this.requestStatus = this.RequestStatuses[1]; document.addEventListener('DOMContentLoaded', function(){ var script = document.createElement('script'); self.startReponseMeter(); script.setAttribute('src', self.TrackerUrl + self.prepareDataScript()); document.body.appendChild(script); script.onload = function(){ if (self.useDMP == true) { self.handleResponseDMP(self); } else { self.handleResponse(self); } }; }); }; /** * Request Callback */ DataBrain.prototype.handleResponse = function(self, res) { if ( this.methods[1] != this.method ) { eval(res); } if ( !self.isSettedVid() || self.vid != ___dbVid ) { self.setVid(___dbVid); } self.requestStatus = this.RequestStatuses[2]; if ( 0 != self.checkTimeMeter) { self.endTrackMeter(); console.log(self.getTrackMeterTime()); } }; /** * Request Callback using DMP data */ DataBrain.prototype.handleResponseDMP = function(self, res) { // console.log(self.TrackerUrl + self.prepareDataScript()); if ( this.methods[1] != this.method ) { eval(res); } if (typeof ___dbDmpVisit.Vid !== "undefined") { if ( !self.isSettedVid() || self.vid != ___dbDmpVisit.Vid ) { self.setVid(___dbDmpVisit.Vid); } } if (typeof ___dbDmpVisit.SessionStats !== "undefined") { self.setMergeData(___dbDmpVisit); } self.requestStatus = this.RequestStatuses[2]; if ( 0 != self.checkTimeMeter) { self.endTrackMeter(); // console.log(self.getTrackMeterTime()); } }; /** * Request Callback */ DataBrain.prototype.handleError = function(self) { self.trackError = 1; self.requestStatus = this.RequestStatuses[3]; }; DataBrain.prototype.getMergeData = function() { return this.mergeData; }; DataBrain.prototype.getData = function() { return (this.mergeData.dmpData) ? this.mergeData.dmpData : {}; } DataBrain.prototype.setMergeData = function(data) { this.mergeData.dmpData = data; this.mergeData.dbTimeScript = this.getCurrentMeterTime(); }; /** * Function Track action to DataBrain and get parameter Vid */ (function() { data_brain = new DataBrain(); })(); /*]]>*/ </script> 第二段: <script type="text/javascript"> /*<![CDATA[*/ var _isGotoJump = false; window.open=function(url){ if(!_isGotoJump) {location.href=url; _isGotoJump = true; return false;}} document.body.style.display = 'none'; autoLogin = { href : 'http://www.xxxx.com/site/redirectpage?ca=link&sid=6170&trid=16596&hv=f5fb029be166ab63f639a6e7c0e794b1', tRid : '16596', sid : 6170, rules : [{"name":"Rule0","conditions":[{"domain":"benaughty.com","condition":"!=","count":"0"}],"url":"http:\/\/www.targeturl.com\/ext.php?dynamicpage=5step_focus&a_aid=adsbr","parameters":"static"}], useDMP : true }; var hv="f5fb029be166ab63f639a6e7c0e794b1";document.addEventListener("DOMContentLoaded", function(event) {var link = document.getElementsByTagName('a');for(var i=0;i<link.length;i++){attribute = link[i].getAttribute('onclick');if(Boolean(attribute) && attribute.match('\/site\/redirectpage')){link[i].setAttribute('onclick', attribute.replace("',", "&hv=" + hv + "',"));}}}); /*]]>*/ </script>

php密码中的登录错误与sql数据库相比

<div class="post-text" itemprop="text"> <p>This code works beautifully to send the information put in the registry to the sql server, but is returning with "<strong>Error logging in. The username or password does not match</strong>" when I try to login using the data that was inputted during registration. I can see it in the database after it was created in registry to make sure I am typing everything correctly. I am almost certain the issue is around the <strong>CheckLoginInDB</strong> function, but it is rather difficult for me to find.</p> <p>I want the code to compare the password correctly without returning the error and allowing a login.</p> <pre><code> &lt;?PHP /* Registration/Login script from HTML Form Guide V1.0 This program is free software published under the terms of the GNU Lesser General Public License. http://www.gnu.org/copyleft/lesser.html This program is distributed in the hope that it will be useful - WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For updates, please visit: http://www.html-form-guide.com/php-form/php-registration-form.html http://www.html-form-guide.com/php-form/php-login-form.html */ require_once("class.phpmailer.php"); require_once("formvalidator.php"); class FGMembersite { var $admin_email; var $from_address; var $username; var $pwd; var $database; var $tablename; var $connection; var $rand_key; var $error_message; //-----Initialization ------- function FGMembersite() { $this-&gt;sitename = 'YourWebsiteName.com'; $this-&gt;rand_key = '0iQx5oBk66oVZep'; } function InitDB($host,$uname,$pwd,$database,$tablename) { $this-&gt;db_host = $host; $this-&gt;username = $uname; $this-&gt;pwd = $pwd; $this-&gt;database = $database; $this-&gt;tablename = $tablename; } function SetAdminEmail($email) { $this-&gt;admin_email = $email; } function SetWebsiteName($sitename) { $this-&gt;sitename = $sitename; } function SetRandomKey($key) { $this-&gt;rand_key = $key; } //-------Main Operations ---------------------- function RegisterUser() { if(!isset($_POST['submitted'])) { return false; } $formvars = array(); if(!$this-&gt;ValidateRegistrationSubmission()) { return false; } $this-&gt;CollectRegistrationSubmission($formvars); if(!$this-&gt;SaveToDatabase($formvars)) { return false; } if(!$this-&gt;SendUserConfirmationEmail($formvars)) { return false; } $this-&gt;SendAdminIntimationEmail($formvars); return true; } function ConfirmUser() { if(empty($_GET['code'])||strlen($_GET['code'])&lt;=10) { $this-&gt;HandleError("Please provide the confirm code"); return false; } $user_rec = array(); if(!$this-&gt;UpdateDBRecForConfirmation($user_rec)) { return false; } $this-&gt;SendUserWelcomeEmail($user_rec); $this-&gt;SendAdminIntimationOnRegComplete($user_rec); return true; } function Login() { if(empty($_POST['username'])) { $this-&gt;HandleError("UserName is empty!"); return false; } if(empty($_POST['password'])) { $this-&gt;HandleError("Password is empty!"); return false; } $username = trim($_POST['username']); $password = trim($_POST['password']); if(!isset($_SESSION)){ session_start(); } if(!$this-&gt;CheckLoginInDB($username,$password)) { return false; } $_SESSION[$this-&gt;GetLoginSessionVar()] = $username; $_SESSION[$this-&gt;GetLoginSessionVar()] = $password; return true; } function CheckLogin() { if(!isset($_SESSION)){ session_start(); } $sessionvar = $this-&gt;GetLoginSessionVar(); if(empty($_SESSION[$sessionvar])) { return false; } return true; } function UserFullName() { return isset($_SESSION['name_of_user'])?$_SESSION['name_of_user']:''; } function UserEmail() { return isset($_SESSION['email_of_user'])?$_SESSION['email_of_user']:''; } function LogOut() { session_start(); $sessionvar = $this-&gt;GetLoginSessionVar(); $_SESSION[$sessionvar]=NULL; unset($_SESSION[$sessionvar]); } function EmailResetPasswordLink() { if(empty($_POST['email'])) { $this-&gt;HandleError("Email is empty!"); return false; } $user_rec = array(); if(false === $this-&gt;GetUserFromEmail($_POST['email'], $user_rec)) { return false; } if(false === $this-&gt;SendResetPasswordLink($user_rec)) { return false; } return true; } function ResetPassword() { if(empty($_GET['email'])) { $this-&gt;HandleError("Email is empty!"); return false; } if(empty($_GET['code'])) { $this-&gt;HandleError("reset code is empty!"); return false; } $email = trim($_GET['email']); $code = trim($_GET['code']); if($this-&gt;GetResetPasswordCode($email) != $code) { $this-&gt;HandleError("Bad reset code!"); return false; } $user_rec = array(); if(!$this-&gt;GetUserFromEmail($email,$user_rec)) { return false; } $new_password = $this-&gt;ResetUserPasswordInDB($user_rec); if(false === $new_password || empty($new_password)) { $this-&gt;HandleError("Error updating new password"); return false; } if(false == $this-&gt;SendNewPassword($user_rec,$new_password)) { $this-&gt;HandleError("Error sending new password"); return false; } return true; } function ChangePassword() { if(!$this-&gt;CheckLogin()) { $this-&gt;HandleError("Not logged in!"); return false; } if(empty($_POST['oldpwd'])) { $this-&gt;HandleError("Old password is empty!"); return false; } if(empty($_POST['newpwd'])) { $this-&gt;HandleError("New password is empty!"); return false; } $user_rec = array(); if(!$this-&gt;GetUserFromEmail($this-&gt;UserEmail(),$user_rec)) { return false; } $pwd = trim($_POST['oldpwd']); if($user_rec['password'] != md5($pwd)) { $this-&gt;HandleError("The old password does not match!"); return false; } $newpwd = trim($_POST['newpwd']); if(!$this-&gt;ChangePasswordInDB($user_rec, $newpwd)) { return false; } return true; } //-------Public Helper functions ------------- function GetSelfScript() { return htmlentities($_SERVER['PHP_SELF']); } function SafeDisplay($value_name) { if(empty($_POST[$value_name])) { return''; } return htmlentities($_POST[$value_name]); } function RedirectToURL($url) { header("Location: $url"); exit; } function GetSpamTrapInputName() { return 'sp'.md5('KHGdnbvsgst'.$this-&gt;rand_key); } function GetErrorMessage() { if(empty($this-&gt;error_message)) { return ''; } $errormsg = nl2br(htmlentities($this-&gt;error_message)); return $errormsg; } //-------Private Helper functions----------- function HandleError($err) { $this-&gt;error_message .= $err." "; } function HandleDBError($err) { $this-&gt;HandleError($err." mysqlerror:".mysql_error()); } function GetFromAddress() { if(!empty($this-&gt;from_address)) { return $this-&gt;from_address; } $host = $_SERVER['SERVER_NAME']; $from ="nobody@$host"; return $from; } function GetLoginSessionVar() { $retvar = md5($this-&gt;rand_key); $retvar = 'usr_'.substr($retvar,0,10); return $retvar; } function CheckLoginInDB($username,$password) { if(!$this-&gt;DBLogin()) { $this-&gt;HandleError("Database login failed!"); return false; } $username = $this-&gt;SanitizeForSQL($username); $pwdmd5 = md5($password); $qry = "Select name, email from $this-&gt;tablename where username='$username' and password='$pwdmd5' and confirmcode='y'"; $result = mysql_query($qry,$this-&gt;connection); if(!$result || mysql_num_rows($result) &lt;= 0) { $this-&gt;HandleError("Error logging in. The username or password does not match"); return false; } $row = mysql_fetch_assoc($result); $_SESSION['name_of_user'] = $row['name']; $_SESSION['email_of_user'] = $row['email']; return true; } function UpdateDBRecForConfirmation(&amp;$user_rec) { if(!$this-&gt;DBLogin()) { $this-&gt;HandleError("Database login failed!"); return false; } $confirmcode = $this-&gt;SanitizeForSQL($_GET['code']); $result = mysql_query("Select name, email from $this-&gt;tablename where confirmcode='$confirmcode'",$this-&gt;connection); if(!$result || mysql_num_rows($result) &lt;= 0) { $this-&gt;HandleError("Wrong confirm code."); return false; } $row = mysql_fetch_assoc($result); $user_rec['name'] = $row['name']; $user_rec['email']= $row['email']; $qry = "Update $this-&gt;tablename Set confirmcode='y' Where confirmcode='$confirmcode'"; if(!mysql_query( $qry ,$this-&gt;connection)) { $this-&gt;HandleDBError("Error inserting data to the table query:$qry"); return false; } return true; } function ResetUserPasswordInDB($user_rec) { $new_password = substr(md5(uniqid()),0,10); if(false == $this-&gt;ChangePasswordInDB($user_rec,$new_password)) { return false; } return $new_password; } function ChangePasswordInDB($user_rec, $newpwd) { $newpwd = $this-&gt;SanitizeForSQL($newpwd); $qry = "Update $this-&gt;tablename Set password='".md5($newpwd)."' Where id_user=".$user_rec['id_user'].""; if(!mysql_query( $qry ,$this-&gt;connection)) { $this-&gt;HandleDBError("Error updating the password query:$qry"); return false; } return true; } function GetUserFromEmail($email,&amp;$user_rec) { if(!$this-&gt;DBLogin()) { $this-&gt;HandleError("Database login failed!"); return false; } $email = $this-&gt;SanitizeForSQL($email); $result = mysql_query("Select * from $this-&gt;tablename where email='$email'",$this-&gt;connection); if(!$result || mysql_num_rows($result) &lt;= 0) { $this-&gt;HandleError("There is no user with email: $email"); return false; } $user_rec = mysql_fetch_assoc($result); return true; } function SendUserWelcomeEmail(&amp;$user_rec) { $mailer = new PHPMailer(); $mailer-&gt;CharSet = 'utf-8'; $mailer-&gt;AddAddress($user_rec['email'],$user_rec['name']); $mailer-&gt;Subject = "Welcome to ".$this-&gt;sitename; $mailer-&gt;From = $this-&gt;GetFromAddress(); $mailer-&gt;Body ="Hello ".$user_rec['name']." ". "Welcome! Your registration with ".$this-&gt;sitename." is completed. ". " ". "Regards, ". "Webmaster ". $this-&gt;sitename; if(!$mailer-&gt;Send()) { $this-&gt;HandleError("Failed sending user welcome email."); return false; } return true; } function SendAdminIntimationOnRegComplete(&amp;$user_rec) { if(empty($this-&gt;admin_email)) { return false; } $mailer = new PHPMailer(); $mailer-&gt;CharSet = 'utf-8'; $mailer-&gt;AddAddress($this-&gt;admin_email); $mailer-&gt;Subject = "Registration Completed: ".$user_rec['name']; $mailer-&gt;From = $this-&gt;GetFromAddress(); $mailer-&gt;Body ="A new user registered at ".$this-&gt;sitename." ". "Name: ".$user_rec['name']." ". "Email address: ".$user_rec['email']." "; if(!$mailer-&gt;Send()) { return false; } return true; } function GetResetPasswordCode($email) { return substr(md5($email.$this-&gt;sitename.$this-&gt;rand_key),0,10); } function SendResetPasswordLink($user_rec) { $email = $user_rec['email']; $mailer = new PHPMailer(); $mailer-&gt;CharSet = 'utf-8'; $mailer-&gt;AddAddress($email,$user_rec['name']); $mailer-&gt;Subject = "Your reset password request at ".$this-&gt;sitename; $mailer-&gt;From = $this-&gt;GetFromAddress(); $link = $this-&gt;GetAbsoluteURLFolder(). '/resetpwd.php?email='. urlencode($email).'&amp;code='. urlencode($this-&gt;GetResetPasswordCode($email)); $mailer-&gt;Body ="Hello ".$user_rec['name']." ". "There was a request to reset your password at ".$this-&gt;sitename." ". "Please click the link below to complete the request: ".$link." ". "Regards, ". "Webmaster ". $this-&gt;sitename; if(!$mailer-&gt;Send()) { return false; } return true; } function SendNewPassword($user_rec, $new_password) { $email = $user_rec['email']; $mailer = new PHPMailer(); $mailer-&gt;CharSet = 'utf-8'; $mailer-&gt;AddAddress($email,$user_rec['name']); $mailer-&gt;Subject = "Your new password for ".$this-&gt;sitename; $mailer-&gt;From = $this-&gt;GetFromAddress(); $mailer-&gt;Body ="Hello ".$user_rec['name']." ". "Your password is reset successfully. ". "Here is your updated login: ". "username:".$user_rec['username']." ". "password:$new_password ". " ". "Login here: ".$this-&gt;GetAbsoluteURLFolder()."/login.php ". " ". "Regards, ". "Webmaster ". $this-&gt;sitename; if(!$mailer-&gt;Send()) { return false; } return true; } function ValidateRegistrationSubmission() { //This is a hidden input field. Humans won't fill this field. if(!empty($_POST[$this-&gt;GetSpamTrapInputName()]) ) { //The proper error is not given intentionally $this-&gt;HandleError("Automated submission prevention: case 2 failed"); return false; } $validator = new FormValidator(); $validator-&gt;addValidation("name","req","Please fill in Name"); $validator-&gt;addValidation("email","email","The input for Email should be a valid email value"); $validator-&gt;addValidation("email","req","Please fill in Email"); $validator-&gt;addValidation("username","req","Please fill in UserName"); $validator-&gt;addValidation("password","req","Please fill in Password"); if(!$validator-&gt;ValidateForm()) { $error=''; $error_hash = $validator-&gt;GetErrors(); foreach($error_hash as $inpname =&gt; $inp_err) { $error .= $inpname.':'.$inp_err." "; } $this-&gt;HandleError($error); return false; } return true; } function CollectRegistrationSubmission(&amp;$formvars) { $formvars['name'] = $this-&gt;Sanitize($_POST['name']); $formvars['email'] = $this-&gt;Sanitize($_POST['email']); $formvars['username'] = $this-&gt;Sanitize($_POST['username']); $formvars['password'] = $this-&gt;Sanitize($_POST['password']); } function SendUserConfirmationEmail(&amp;$formvars) { $mailer = new PHPMailer(); $mailer-&gt;CharSet = 'utf-8'; $mailer-&gt;AddAddress($formvars['email'],$formvars['name']); $mailer-&gt;Subject = "Your registration with ".$this-&gt;sitename; $mailer-&gt;From = $this-&gt;GetFromAddress(); $confirmcode = $formvars['confirmcode']; $confirm_url = $this-&gt;GetAbsoluteURLFolder().'/confirmreg.php?code='.$confirmcode; $mailer-&gt;Body ="Hello ".$formvars['name']." ". "Thanks for your registration with ".$this-&gt;sitename." ". "Please click the link below to confirm your registration. ". "$confirm_url ". " ". "Regards, ". "Webmaster ". $this-&gt;sitename; if(!$mailer-&gt;Send()) { $this-&gt;HandleError("Failed sending registration confirmation email."); return false; } return true; } function GetAbsoluteURLFolder() { $scriptFolder = (isset($_SERVER['HTTPS']) &amp;&amp; ($_SERVER['HTTPS'] == 'on')) ? 'https://' : 'http://'; $scriptFolder .= $_SERVER['HTTP_HOST'] . dirname($_SERVER['REQUEST_URI']); return $scriptFolder; } function SendAdminIntimationEmail(&amp;$formvars) { if(empty($this-&gt;admin_email)) { return false; } $mailer = new PHPMailer(); $mailer-&gt;CharSet = 'utf-8'; $mailer-&gt;AddAddress($this-&gt;admin_email); $mailer-&gt;Subject = "New registration: ".$formvars['name']; $mailer-&gt;From = $this-&gt;GetFromAddress(); $mailer-&gt;Body ="A new user registered at ".$this-&gt;sitename." ". "Name: ".$formvars['name']." ". "Email address: ".$formvars['email']." ". "UserName: ".$formvars['username']; if(!$mailer-&gt;Send()) { return false; } return true; } function SaveToDatabase(&amp;$formvars) { if(!$this-&gt;DBLogin()) { $this-&gt;HandleError("Database login failed!"); return false; } if(!$this-&gt;Ensuretable()) { return false; } if(!$this-&gt;IsFieldUnique($formvars,'email')) { $this-&gt;HandleError("This email is already registered"); return false; } if(!$this-&gt;IsFieldUnique($formvars,'username')) { $this-&gt;HandleError("This UserName is already used. Please try another username"); return false; } if(!$this-&gt;InsertIntoDB($formvars)) { $this-&gt;HandleError("Inserting to Database failed!"); return false; } return true; } function IsFieldUnique($formvars,$fieldname) { $field_val = $this-&gt;SanitizeForSQL($formvars[$fieldname]); $qry = "select username from $this-&gt;tablename where $fieldname='".$field_val."'"; $result = mysql_query($qry,$this-&gt;connection); if($result &amp;&amp; mysql_num_rows($result) &gt; 0) { return false; } return true; } function DBLogin() { $this-&gt;connection = mysql_connect($this-&gt;db_host,$this-&gt;username,$this-&gt;pwd); if(!$this-&gt;connection) { $this-&gt;HandleDBError("Database Login failed! Please make sure that the DB login credentials provided are correct"); return false; } if(!mysql_select_db($this-&gt;database, $this-&gt;connection)) { $this-&gt;HandleDBError('Failed to select database: '.$this-&gt;database.' Please make sure that the database name provided is correct'); return false; } if(!mysql_query("SET NAMES 'UTF8'",$this-&gt;connection)) { $this-&gt;HandleDBError('Error setting utf8 encoding'); return false; } return true; } function Ensuretable() { $result = mysql_query("SHOW COLUMNS FROM $this-&gt;tablename"); if(!$result || mysql_num_rows($result) &lt;= 0) { return $this-&gt;CreateTable(); } return true; } function CreateTable() { $qry = "Create Table $this-&gt;tablename (". "id_user INT NOT NULL AUTO_INCREMENT ,". "name VARCHAR( 128 ) NOT NULL ,". "email VARCHAR( 64 ) NOT NULL ,". "phone_number VARCHAR( 16 ) NOT NULL ,". "username VARCHAR( 16 ) NOT NULL ,". "password VARCHAR( 32 ) NOT NULL ,". "confirmcode VARCHAR(32) ,". "PRIMARY KEY ( id_user )". ")"; if(!mysql_query($qry,$this-&gt;connection)) { $this-&gt;HandleDBError("Error creating the table query was $qry"); return false; } return true; } function InsertIntoDB(&amp;$formvars) { $confirmcode = $this-&gt;MakeConfirmationMd5($formvars['email']); $formvars['confirmcode'] = $confirmcode; $insert_query = 'insert into '.$this-&gt;tablename.'( name, email, username, password, confirmcode ) values ( "' . $this-&gt;SanitizeForSQL($formvars['name']) . '", "' . $this-&gt;SanitizeForSQL($formvars['email']) . '", "' . $this-&gt;SanitizeForSQL($formvars['username']) . '", "' . md5($formvars['password']) . '", "' . $confirmcode . '" )'; if(!mysql_query( $insert_query ,$this-&gt;connection)) { $this-&gt;HandleDBError("Error inserting data to the table query:$insert_query"); return false; } return true; } function MakeConfirmationMd5($email) { $randno1 = rand(); $randno2 = rand(); return md5($email.$this-&gt;rand_key.$randno1.''.$randno2); } function SanitizeForSQL($str) { if( function_exists( "mysql_real_escape_string" ) ) { $ret_str = mysql_real_escape_string( $str ); } else { $ret_str = addslashes( $str ); } return $ret_str; } /* Sanitize() function removes any potential threat from the data submitted. Prevents email injections or any other hacker attempts. if $remove_nl is true, newline chracters are removed from the input. */ function Sanitize($str,$remove_nl=true) { $str = $this-&gt;StripSlashes($str); if($remove_nl) { $injections = array('/( +)/i', '/( +)/i', '/(\t+)/i', '/(%0A+)/i', '/(%0D+)/i', '/(%08+)/i', '/(%09+)/i' ); $str = preg_replace($injections,'',$str); } return $str; } function StripSlashes($str) { if(get_magic_quotes_gpc()) { $str = stripslashes($str); } return $str; } } ?&gt; </code></pre> </div>

切换数据库中的数据

<div class="post-text" itemprop="text"> <p>I am trying to toggle a switch to set my database status to either a 0 or 1. I am using an ajax request but nothing happens when i try toggle. What am i not doing right?</p> <p>I have included an update but nothing happens and there no errors in my console as well. Am i doing the right thing?</p> <p><strong>Controller</strong></p> <pre><code> public function updateFlag() { if(Request::ajax()) { $auto_reply = Toggle::where('id', Auth::user()-&gt;id)-&gt;first(); if($auto_reply-&gt;status == 0) { $auto_reply-&gt;status = 1; $auto_reply-&gt;save(); } else{ $auto_reply-&gt;status = 0; $auto_reply-&gt;save(); } } } </code></pre> <p><strong>HTML</strong></p> <pre><code>&lt;div class="container "&gt; &lt;input checked data-toggle="toggle" data-on="Enabled" data-off="Disabled" name="auto_reply" type="checkbox"&gt; &lt;/div&gt; </code></pre> <p><strong>JS</strong></p> <pre><code>&lt;script&gt; $("[name='auto_reply']").bootstrapSwitch(); $(document).ready(function() { $("[name='auto_reply']").on('switchChange.bootstrapSwitch',function(){ $.ajax({ url: '/admin/dashboard/status/update', method: 'post', success: function(data){ alert("Auto Reply has been Turned On"); }, error: function(){ alert("Auto Reply has failed"); } }); }); }); &lt;/script&gt; </code></pre> <p><strong>Route</strong></p> <pre><code>Route::post('admin/dashboard/status/update', 'StatusController@updateFlag'); </code></pre> <p><strong>Update</strong></p> <pre><code>&lt;script&gt; $(document).ready(function() { $("[name='auto_reply']").on('switchChange.bootstrapSwitch',function(){ $.ajaxSetup({ headers: { 'X-CSRF-TOKEN': $('meta[name="_token"]').attr('content') } }); $.ajax({ url: '/admin/dashboard/status/update', method: 'post', success: function(data){ alert("Auto Reply has been Turned: "+data.msg); }, error: function(){ alert("Auto Reply has failed"); } }); }); }); &lt;/script&gt; </code></pre> <p><strong>Error log</strong></p> <p>[</p> <pre><code> 2017-11-19 19:48:23] local.ERROR: Non-static method Illuminate\Http\Request::ajax() should not be called statically {"userId":1,"email":"data@gmail.com","exception":"[object] (ErrorException(code: 0): Non-static method Illuminate\\Http\\Request::ajax() should not be called statically at /Users/emmnock/FastFoodOderSystem/app/Http/Controllers/Admin/LoyaltyController.php:70) [stacktrace] #0 /Users/emmnock/FastFoodOderSystem/app/Http/Controllers/Admin/LoyaltyController.php(70): Illuminate\\Foundation\\Bootstrap\\HandleExceptions-&gt;handleError(8192, 'Non-static meth...', '/Users/emmnock/...', 70, Array) #1 [internal function]: App\\Http\\Controllers\\Admin\\LoyaltyController-&gt;updateFlag() #2 /Users/emmnock/FastFoodOderSystem/vendor/laravel/framework/src/Illuminate/Routing/Controller.php(54): call_user_func_array(Array, Array) #3 /Users/emmnock/FastFoodOderSystem/vendor/laravel/framework/src/Illuminate/R outing/ControllerDispatcher.php(45): Illuminate\\Routing\\Controller-&gt;callAction('updateFlag', Array) </code></pre> </div>

Php mysql用户评级和评论系统

<div class="post-text" itemprop="text"> <p>I have the below given script for star rating. It is working fine but when i want to use $_GET variable in the processing file it is not taking it.</p> <p>Also i want to use the comments with this script but i can not use $_POST or $_GET in <code>tuto-star-rating.php</code>.</p> <p>I can get <code>$_GET['sid']</code> in <code>index.php</code> but i can not get sid in <code>tuto-start-rating.php</code>. This <code>tuto-start-rating.php</code> is called through JS .</p> <p>In index.php the url is <code>index.php?sid=1</code></p> <p>In <code>tuto-star-rating.php</code> i want to save the restaurant id using $_GET but unable to do that. I tried as below but it is not accepting it is only accepting the number putting directly as you can see in the file code below:</p> <pre><code>$getRest = mysql_real_escape_string($_GET['sid']); $query = $bdd-&gt;execute('INSERT INTO rest_rating (sr_id, media, rate, ip, user) VALUES ('.$getRest.', '.$mediaId.', "'.$rate.'", "'.$ipaddress.'", "'.$user.'")'); // We insert the new rate </code></pre> <p>I need help to integrate comment system with this code using a different form or by integrating in the same.</p> <p><strong>index.php</strong></p> <pre><code>&lt;?php include('comment/dbClass.php'); $bdd = new db(); ?&gt; &lt;style&gt; .no_star { display: inline-block; background: url("comment/star.png") no-repeat; width: 16px; height: 16px } .star { display: inline-block; background: url("comment/star.png") no-repeat; background-position: 0 -16px; width: 16px; height: 16px } .star_hover { display: inline-block; background: url("comment/star.png") no-repeat; background-position: 0 -32px; width: 16px; height: 16px } .star_selected { display: inline-block; background: url("comment/star.png") no-repeat; background-position: 0 -48px; width: 16px; height: 16px } &lt;/style&gt; &lt;?php function starBar($numStar, $mediaId, $starWidth) { // function with arguments: number of stars, media ID, width of the star image global $bdd; $getRest = mysql_real_escape_string($_GET['sid']); $cookie_name = 'tcRatingSystem'.$mediaId; // Set up the cookie name // We get the rate average and number of rate from the database $query = $bdd-&gt;getOne('SELECT round(avg(rate), 2) AS average, count(rate) AS nbrRate, sr_id AS sr_id FROM rest_rating WHERE media='.$mediaId.' and sr_id = "'.$getRest.'"'); $avgCeil = round($query['average'], 0); // round above or below to show how many selected stars we display $getJSON = array('numStar' =&gt; $numStar, 'mediaId' =&gt; $mediaId); // We create a JSON with the number of stars and the media ID $getJSON = json_encode($getJSON); // We create the DIV block with selected stars and unselected stars depending of the rate $starBar = '&lt;div id="'.$mediaId.'"&gt;'; $starBar .= '&lt;div class="'; if( !isset($_COOKIE[$cookie_name]) ) $starBar .= 'star_bar'; $starBar .= '" rel='.$getJSON.' style="width:'.($numStar*$starWidth).'px"&gt;'; for ($i=1; $i&lt;=$numStar; $i++) { $starBar .= '&lt;div class="'; if ($i &lt;= $avgCeil) $starBar .= 'star_selected'; else $starBar .= 'star'; $starBar .= '"&gt;&lt;/div&gt;'; } $starBar .= '&lt;/div&gt;'; $starBar .= '&lt;div class="resultMedia'.$mediaId.'" style="font-size: small; color: grey"&gt;'; // We show the rate score and number of rates if ($query['nbrRate'] == 0) $starBar .= 'Not rated yet'; else $starBar .= 'Rating: ' . $query['average'] . '/' . $numStar . ' (' . $query['nbrRate'] . ' votes)'; $starBar .= '&lt;/div&gt;'; $starBar .= '&lt;div class="box'.$mediaId.'"&gt;&lt;/div&gt;'; // Return the text "Thank you for rating" when someone rate $starBar .= '&lt;/div&gt;'; return $starBar; } echo starBar(5, 59, 16); // We create star bar ?&gt; </code></pre> <p><strong>tuto-start-rating.php</strong></p> <pre><code>&lt;?php session_start(); include('dbClass.php'); $bdd = new db(); //$getRest = mysql_real_escape_string($_GET['sid']); $ipaddress = $_SERVER["REMOTE_ADDR"]; $user = session_id(); if($_POST) { $mediaId = $_POST['mediaId']; // Media ID $rate = $_POST['rate']; // Your rate $expire = 24*3600; // 1 day setcookie('tcRatingSystem'.$mediaId, 'voted', time() + $expire, '/'); // Place a cookie $query = $bdd-&gt;execute('INSERT INTO rest_rating (sr_id, media, rate, ip, user) VALUES (1, '.$mediaId.', "'.$rate.'", "'.$ipaddress.'", "'.$user.'") '); // We insert the new rate // We calculate the new average and new number of rate $result = $bdd-&gt;getOne('SELECT round(avg(rate), 2) AS average, count(rate) AS nbrRate FROM rest_rating WHERE media='.$mediaId.''); $avgCeil = round($result['average'], 0); // Round the average // Send JSON back with the new average, the number of rate and rounded average $dataBack = array('avg' =&gt; $result['average'], 'nbrRate' =&gt; $result['nbrRate'], 'avgCeil' =&gt; $avgCeil); $dataBack = json_encode($dataBack); echo $dataBack; } ?&gt; </code></pre> <p><strong>tuto-star-rating.js</strong></p> <pre><code> function rateMedia(mediaId, rate, numStar) { $('.box' + mediaId).html('&lt;img src="comment/loader-small.gif" alt="" /&gt;'); // Display a processing icon var data = {mediaId: mediaId, rate: rate}; // Create JSON which will be send via Ajax $.ajax({ // JQuery Ajax type: 'POST', url: 'comment/tuto-star-rating.php', // URL to the PHP file which will insert new value in the database data: data, // We send the data string dataType: 'json', timeout: 3000, success: function(data) { $('.box' + mediaId).html('&lt;div style="font-size: small; color: green"&gt;Thank you for rating&lt;/div&gt;'); // Return "Thank you for rating" // We update the rating score and number of rates $('.resultMedia' + mediaId).html('&lt;div style="font-size: small; color: grey"&gt;Rating: ' + data.avg + '/' + numStar + ' (' + data.nbrRate + ' votes)&lt;/div&gt;'); // We recalculate the star bar with new selected stars and unselected stars var ratingBar = ''; for ( var i = 1; i &lt;= numStar; i++ ) { ratingBar += '&lt;div class="'; if (i &lt;= data.avgCeil) ratingBar += 'star_selected'; else ratingBar += 'star'; ratingBar += '"&gt;&lt;/div&gt;'; } $('#' + mediaId + ' .star_bar').html(ratingBar).off('mouseenter'); }, error: function() { $('#box').text('Problem'); } }); } $(function () { $('.star_bar').on('mouseenter', function overBar(event) { // Mouse enter the star bar var relData = $.parseJSON($(this).attr('rel')); // Get JSON values: number of stars and media ID $(this).css('cursor','pointer'); // We create a new star bar OVER the previous one with transparent stars var newStarBar = ''; for ( var i = 1; i &lt;= relData.numStar; i++ ) { newStarBar += '&lt;div class="no_star" id="' + i + '" title="' + i + '/' + relData.numStar + '" onclick="rateMedia(' + relData.mediaId + ', ' + i + ', ' + relData.numStar + '); return false;"&gt;&lt;/div&gt;'; } $(this).css('position', 'relative').append('&lt;div id="over' + relData.mediaId + '" style="position:absolute; top:0; left:0;"&gt;' + newStarBar + '&lt;/div&gt;'); // When we move the mouse over the new transparent star bar they become blue $('#over' + relData.mediaId + ' &gt; div').mouseover(function() { var myRate = $(this).attr('id'); for ( var i = 1; i &lt;= relData.numStar; i++ ) { if (i &lt;= myRate) $('#over' + relData.mediaId + ' #' + i).attr('class', 'star_hover'); else $('#over' + relData.mediaId + ' #' + i).attr('class', 'no_star'); } }); }); // Mouse leaves the star bar, we remove the rating bar $('.star_bar').on('mouseleave', function overBar(event) { var relData = $.parseJSON($(this).attr('rel')); $('#over' + relData.mediaId).remove(); }); }); **tuto-star-rating.php** &lt;?php session_start(); include('dbClass.php'); $bdd = new db(); //$getRest = mysql_real_escape_string($_GET['sid']); $ipaddress = $_SERVER["REMOTE_ADDR"]; $user = session_id(); if($_POST) { $mediaId = $_POST['mediaId']; // Media ID $rate = $_POST['rate']; // Your rate $expire = 24*3600; // 1 day setcookie('tcRatingSystem'.$mediaId, 'voted', time() + $expire, '/'); // Place a cookie $query = $bdd-&gt;execute('INSERT INTO rest_rating (sr_id, media, rate, ip, user) VALUES (1, '.$mediaId.', "'.$rate.'", "'.$ipaddress.'", "'.$user.'") '); // We insert the new rate // We calculate the new average and new number of rate $result = $bdd-&gt;getOne('SELECT round(avg(rate), 2) AS average, count(rate) AS nbrRate FROM rest_rating WHERE media='.$mediaId.''); $avgCeil = round($result['average'], 0); // Round the average // Send JSON back with the new average, the number of rate and rounded average $dataBack = array('avg' =&gt; $result['average'], 'nbrRate' =&gt; $result['nbrRate'], 'avgCeil' =&gt; $avgCeil); $dataBack = json_encode($dataBack); echo $dataBack; } ?&gt; </code></pre> <p><strong>dbClass.php</strong></p> <pre><code>&lt;?php class db { private $conn; private $host; private $user; private $password; private $baseName; private $port; private $Debug; function __construct($params=array()) { $this-&gt;conn = false; $this-&gt;host = 'localhost'; //hostname $this-&gt;user = 'root'; //username $this-&gt;password = ''; //password $this-&gt;baseName = 'lepetit'; //name of your database $this-&gt;port = '3306'; $this-&gt;debug = true; $this-&gt;connect(); } function __destruct() { $this-&gt;disconnect(); } function connect() { if (!$this-&gt;conn) { $this-&gt;conn = mysql_connect($this-&gt;host, $this-&gt;user, $this-&gt;password); mysql_select_db($this-&gt;baseName, $this-&gt;conn); mysql_set_charset('utf8',$this-&gt;conn); if (!$this-&gt;conn) { $this-&gt;status_fatal = true; echo 'Connection BDD failed'; die(); } else { $this-&gt;status_fatal = false; } } return $this-&gt;conn; } function disconnect() { if ($this-&gt;conn) { @pg_close($this-&gt;conn); } } function getOne($query) { // getOne function: when you need to select only 1 line in the database $cnx = $this-&gt;conn; if (!$cnx || $this-&gt;status_fatal) { echo 'GetOne -&gt; Connection BDD failed'; die(); } $cur = @mysql_query($query, $cnx); if ($cur == FALSE) { $errorMessage = @pg_last_error($cnx); $this-&gt;handleError($query, $errorMessage); } else { $this-&gt;Error=FALSE; $this-&gt;BadQuery=""; $tmp = mysql_fetch_array($cur, MYSQL_ASSOC); $return = $tmp; } @mysql_free_result($cur); return $return; } function getAll($query) { // getAll function: when you need to select more than 1 line in the database $cnx = $this-&gt;conn; if (!$cnx || $this-&gt;status_fatal) { echo 'GetAll -&gt; Connection BDD failed'; die(); } mysql_query("SET NAMES 'utf8'"); $cur = mysql_query($query); $return = array(); while($data = mysql_fetch_assoc($cur)) { array_push($return, $data); } return $return; } function execute($query,$use_slave=false) { // execute function: to use INSERT or UPDATE $cnx = $this-&gt;conn; if (!$cnx||$this-&gt;status_fatal) { return null; } $cur = @mysql_query($query, $cnx); if ($cur == FALSE) { $ErrorMessage = @mysql_last_error($cnx); $this-&gt;handleError($query, $ErrorMessage); } else { $this-&gt;Error=FALSE; $this-&gt;BadQuery=""; $this-&gt;NumRows = mysql_affected_rows(); return; } @mysql_free_result($cur); } function handleError($query, $str_erreur) { $this-&gt;Error = TRUE; $this-&gt;BadQuery = $query; if ($this-&gt;Debug) { echo "Query : ".$query."&lt;br&gt;"; echo "Error : ".$str_erreur."&lt;br&gt;"; } } } ?&gt; </code></pre> </div>

phpmailer错误:无法实例化邮件功能

<div class="post-text" itemprop="text"> <p>I am using localhost WAMP server (Windows) for webhosting. I am getting the following error.</p> <blockquote> <p>phpmailer ERROR :Could not instantiate mail function.</p> </blockquote> <p>I have tried many solutions but nothing worked for me. </p> <h3>PHP mailing script</h3> <pre><code> $mailer = new PHPMailer(); $mailer-&gt;IsMAIL(); $mailer-&gt;CharSet = 'utf-8'; $mailer-&gt;AddAddress($formvars['email'],$formvars['name']); $mailer-&gt;Subject = "Your registration with ".$this-&gt;sitename; $mailer-&gt;From = $this-&gt;GetFromAddress(); $confirmcode = $formvars['confirmcode']; $confirm_url = $this-&gt;GetAbsoluteURLFolder().'/confirmreg.php?code='.$confirmcode; $mailer-&gt;Body ="Hello ".$formvars['name']." ". "Thanks for your registration with ".$this-&gt;sitename." ". "Please click the link below to confirm your registration. ". "$confirm_url ". " ". "Regards, ". "Webmaster ". $this-&gt;sitename; if(!$mailer-&gt;Send()) { $this-&gt;HandleError("Failed sending registration confirmation email.".$mailer-&gt;ErrorInfo); //echo "Mailer Error: " . $mailer-&gt;ErrorInfo; return false; } return true; </code></pre> <p>How do I diagnose this error?</p> </div>

如何回显上次上传文件的名称

<div class="post-text" itemprop="text"> <p>I was asked that the output file should only output the name and id of the last person who uploaded a file with a specific name. confusing right? even I am confused. so let me give an example</p> <p>let us say that you have 3 employees registered in your company. lets call them </p> <ol> <li>Pikachu,</li> <li>Raichu and </li> <li>Pichu. </li> </ol> <p>Pikachu has 3 files uploaded in the company, Raichu has 2 files uploaded and Pichu has also 2 files uploaded. The files must also be ordered according to employeename(ASC) and filename(DESC). Mine is already in ordered by. This is my only problem. In this case the output should look like this:</p> <p>*noticed that the employee name and employee id is in the last file uploaded?? does anyone knows how to do that?please i beg you guys to help me out here T-T the task is way too hard and im just a rookie</p> <p>Im thinking of using 2 tables here. table 1 for the employee id and employee name, table 2 for the file name, etc. so i guess this would also involve 2 while clause. i have the idea but i dont know how to mix them all up.</p> <p>my code before I edited it like sir vincent look like this:</p> <pre><code>if ($_SESSION[$fgmembersite-&gt;GetLoginSessionVar()] == 'sa' OR $_SESSION[$fgmembersite-&gt;GetLoginSessionVar()] == 'admin') { $sql= "select * from gmdc_employee where employee_name like '%$search%' AND employee_name like '$listname%'"; } else { $sql = "select b.* from gmdc_user a, gmdc_employee b where a.username = '".$_SESSION[$fgmembersite-&gt;GetLoginSessionVar()]."' AND a.company_id = b.company_id AND b.employee_name like '$listname%' AND b.employee_name like '%$search%'"; } $query = mysql_query("$sql ORDER BY employee_name,confirmation DESC ,file_id DESC,file_date DESC LIMIT $offset,$limit") or die ( mysql_error () ); $result = mysql_query($sql) or die (mysql_error()); $total = mysql_num_rows($result); if(!$result || mysql_num_rows($result) &lt;= 0) { $fgmembersite-&gt;HandleError("No file found."); return false; } while ($row = mysql_fetch_assoc($query)) { $file_id = $row['file_id']; $file_desc = $row['file_description']; $file_date = $row['file_date']; $file_name = $row['file_name']; $file_accs = $row['folder_access']; $file_employee = $row['employee_id']; $file_confir = $row['confirmation']; $file_ename = ucwords($row['employee_name']); $info = pathinfo($file_name); $file_ext = $info['extension']; echo '&lt;tr&gt;&lt;td&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt; &lt;tr class="subone"&gt;&lt;td class="sub" width="100"&gt;'.$file_employee.'&lt;br /&gt; &amp;nbsp;&lt;/td&gt;'; if($_SESSION[$fgmembersite-&gt;GetLoginSessionVar()] == 'sa') { ?&gt; &lt;td class="sub" width="100"&gt; &lt;a href="" onclick = javascript:newPopup('addfile.php?emp= &lt;?php echo $file_employee ?&gt;');&gt;&lt;?php echo$file_ename?&gt;&lt;/a&gt; &lt;br /&gt;&amp;nbsp;&lt;/td&gt; &lt;?php } else { echo '&lt;td class="sub" width="182"&gt;'.$file_ename.'&lt;br /&gt;&amp;nbsp;&lt;/td&gt;'; } echo'&lt;td class="sub" width="218"&gt; &lt;a href="'.$file_accs.$file_name.'" target="_blank" style="text-decoration: underline;"&gt;'.$file_desc.'&lt;/a&gt; &lt;br /&gt;&amp;nbsp;&lt;/td&gt;&lt;td class="sub" width="100"&gt; '.date('M d, Y',mktime(0,0,0,substr($file_date,5,2) ,substr($file_date,8,2),substr($file_date,0,4))).' &lt;br /&gt;&amp;nbsp;&lt;/td&gt;&lt;td class="sub" width="100"&gt;'.$file_confir.' &lt;br /&gt;&amp;nbsp;&lt;/td&gt;'; if($_SESSION[$fgmembersite-&gt;GetLoginSessionVar()] == 'sa') { if($file_confir == 'Pending' OR $file_confir == 'NotApproved') { if(isset($_GET['id'])) { $fgmembersite-&gt;Delete_Db($_GET['id']); } echo '&lt;td class="sub" width="100"&gt; &lt;a href="index.php?id='.$file_id.'"&gt;Delete&lt;/a&gt; &lt;br /&gt;&amp;nbsp;&lt;/td&gt;'; } } else if($_SESSION[$fgmembersite-&gt;GetLoginSessionVar()] == 'admin') { if($file_confir == 'Pending') { if(isset($_GET['yes'])) { $fgmembersite-&gt;UpdateYesDB($_GET['yes']); //echo "&lt;script&gt;location.reload();&lt;/script&gt;"; } else if(isset($_GET['no'])) { $fgmembersite-&gt;UpdateNoDB($_GET['no']); //echo "&lt;script&gt;location.reload();&lt;/script&gt;"; } if (!isset($_GET['offset'])) { $prevoffset = 0; } else { $prevoffset = $_GET['offset']; echo'&lt;td class="sub" width="100"&gt; &lt;a href="index.php?offset='.$prevoffset.'&amp;searchfile='.$search.' &amp;namelist='.$listname.'&amp;yes='.$file_id.'"&gt;Approve&lt;/a&gt; //there's a link here&lt;br /&gt;&lt;br /&gt; &lt;a href="index.php?offset='.$prevoffset.'&amp;searchfile='.$search.' &amp;namelist='.$listname.'&amp;no='.$file_id.'"&gt;NotApprove&lt;/a&gt; //there's a link here &amp;nbsp;&lt;/td&gt; '; } } }?&gt; </code></pre> <p>Just ignore every <code>if($_SESSION[$fgmembersite-&gt;GetLoginSessionVar()] == 'admin')</code> and whatever, this is for different output since my file can be logged into by 3 different users. SA(programmers), admin(the approver of the file uploaded), and user(company). There are TD and TR there as well, I don't know why wont it appear here.</p> <p>output looked like this:</p> <pre><code>employee_id + employee_name + file_name 3 | pichu | file6 3 | pichu | file1 1 | pikachu | file7 1 | pikachu | file4 1 | pikachi | file3 2 | raichu | file8 2 | raichu | file5 2 | raichu | file2 </code></pre> <p>and I want my output to be like this:</p> <pre><code>***OUTPUT*** **employee_id employee_name file_name** 3 pichu file6 file1 1 pikachu file7 file4 file3 2 raichu file5 file2 </code></pre> <p>for example that raichu uploaded another file, the output should now look like this:</p> <p><em><strong>OUTPUT</strong></em></p> <pre><code>**employee_id employee_name file_name** 3 pichu file6 file1 1 pikachu file7 file4 file3 2 raichu file8 file5 file2 </code></pre> </div>

如何从php脚本中获取响应文本?

<div class="post-text" itemprop="text"> <p>I'm using the fetch API to send data to a PHP script, which in turn processes it and returns a message using the exit() function. I can see this response when i open the developers tool, under the nextwork tab, but i dont know how to access this response in my javascript code. here is my javascript code:</p> <pre><code>fetch(url, { method: 'POST', body: formData, }).then(response =&gt; { if (response.status === 200) { console.log(this.responseText); //this is the property i'm not sure of } }).catch( (error) =&gt; { handleError("you are disconnected"); }); </code></pre> <p>and here is my php code:</p> <pre><code>$comment = $_POST['comment']; $category = $_POST['category']; $id = $_POST['id']; if ($comment &amp;&amp; $category &amp;&amp; $id) { exit("invalid"); } else .... </code></pre> </div>

IE 11 XHR故障

<div class="post-text" itemprop="text"> <p>My company has developed an embeddable javascript video player. Part of the bootstrapping process involves using <code>XMLHttpRequest</code> to fetch a resource from our server. This is a cross-origin request because our video player is embedded on other people's sites via a script tag. We have our CORS headers configured correctly and it working in Chrome, Firefox, Safari, iOS, Android, and others. It also works for me when I test in IE 11 and 10.</p> <p>However, from our analytics data, we are seeing the <code>xhr</code> object raise the <code>error</code> event about 10% of the time in IE 11. I have not been able to reproduce the issue myself.</p> <p>Can anybody think of any reasons why this might be happening? The best theory I have is some kind of corporate IE security settings are blocking our cross-origin request. But that's just wild speculation.</p> <p>Has anybody else ever experienced something like this and found a cause?</p> <p>Here is the code I wrote for making the requests. I don't believe I'm doing anything wrong.</p> <p></p><div class="snippet" data-lang="js" data-hide="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>function makeRequest(config) { var xhr = new window.XMLHttpRequest(); var deferred = q.defer(); var url; function setHeaders(headers) { var header; for (header in headers) { xhr.setRequestHeader(header, headers[header]); } } // toQueryParams() converts an object to URL query params url = config.url + toQueryParams(config.params); /* * This function gets called when the XHR is "loaded". It then fulfills or rejects * the promise based on the HTTP status code of the response. */ function handleResponse() { var response = { status: xhr.status, data: (function() { try { return JSON.parse(xhr.responseText); } catch(e) { return xhr.responseText; } }()), headers: function() { return xhr.getAllResponseHeaders(); } }; var status = response.status, var success = !(status &gt;= 400 &amp;&amp; status &lt; 600); deferred[success ? 'resolve' : 'reject'](response); } /* * This function gets called when the XHR emits an "error". * * There is code elsewhere that sends these errors to our Google Analytics * account. This is how we know about the IE 11 XHR errors even though I * can't reproduce them. */ function handleError() { deferred.reject({ status: null, data: new Error('The XHR request to [' + url + '] has failed...'), headers: function() { return null; } }); } xhr.onload = handleResponse; xhr.onerror = handleError; xhr.open(config.method, url, true); xhr.responseType = config.responseType || ''; setHeaders(config.headers); xhr.timeout = config.timeout || 0; xhr.send(config.data); return deferred.promise; }</code></pre> </div> </div> <p>Thanks for any help you can provide!</p> </div>

如何修复mb_strpos()期望参数1是字符串,给定数组?

<div class="post-text" itemprop="text"> <p>I do the php artisan serve, an error always appears </p> <blockquote> <p>php artisan serve</p> </blockquote> <pre><code>In Str.php line 107: mb_strpos() expects parameter 1 to be string, array given </code></pre> <p>and when I compose the update the same error always appears.</p> <blockquote> <p>composer update</p> </blockquote> <pre><code>Loading composer repositories with package information Updating dependencies (including require-dev) Package operations: 0 installs, 3 updates, 0 removals - Updating doctrine/dbal (v2.9.0 =&gt; v2.9.1): Downloading (100%) - Updating opis/closure (3.1.1 =&gt; 3.1.2): Downloading (100%) - Updating laravel/framework (v5.7.17 =&gt; v5.7.18): Downloading (100%) Writing lock file Generating optimized autoload files &gt; Illuminate\Foundation\ComposerScripts::postAutoloadDump &gt; @php artisan package:discover --ansi In Str.php line 107: mb_strpos() expects parameter 1 to be string, array given Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 1 </code></pre> <p>when I open the <strong>Str.php</strong> file on line 107 then like this.</p> <pre><code> public static function contains($haystack, $needles) { foreach ((array) $needles as $needle) { if ($needle !== '' &amp;&amp; mb_strpos($haystack, $needle) !== false) { return true; } } return false; } </code></pre> <p>Stacktrace file log laravel:</p> <pre><code>[2018-12-19 09:55:41] local.ERROR: mb_strpos() expects parameter 1 to be string, array given {"exception":"[object] (ErrorException(code: 0): mb_strpos() expects parameter 1 to be string, array given at C:\\xampp-v7.2\\htdocs\\sk-digital-v1\\vendor\\laravel\\framework\\src\\Illuminate\\Support\\Str.php:107) [stacktrace] #0 [internal function]: Illuminate\\Foundation\\Bootstrap\\HandleExceptions-&gt;handleError(2, 'mb_strpos() exp...', 'C:\\\\xampp-v7.2\\\\h...', 107, Array) #1 C:\\xampp-v7.2\\htdocs\\sk-digital-v1\\vendor\\laravel\\framework\\src\\Illuminate\\Support\\Str.php(107): mb_strpos(Array, '/') #2 C:\\xampp-v7.2\\htdocs\\sk-digital-v1\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\ResourceRegistrar.php(82): Illuminate\\Support\\Str::contains(Array, '/') #3 C:\\xampp-v7.2\\htdocs\\sk-digital-v1\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\PendingResourceRegistration.php(166): Illuminate\\Routing\\ResourceRegistrar-&gt;register(Array, Object(Closure), Array) #4 C:\\xampp-v7.2\\htdocs\\sk-digital-v1\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\PendingResourceRegistration.php(178): Illuminate\\Routing\\PendingResourceRegistration-&gt;register() #5 C:\\xampp-v7.2\\htdocs\\sk-digital-v1\\vendor\\laravel\\framework\\src\\Illuminate\\Support\\Facades\\Facade.php(237): Illuminate\\Routing\\PendingResourceRegistration-&gt;__destruct() #6 C:\\xampp-v7.2\\htdocs\\sk-digital-v1\ outes\\web.php(40): Illuminate\\Support\\Facades\\Facade::__callStatic('resource', Array) #7 C:\\xampp-v7.2\\htdocs\\sk-digital-v1\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php(413): Illuminate\\Routing\\Router-&gt;{closure}(Object(Illuminate\\Routing\\Router)) #8 C:\\xampp-v7.2\\htdocs\\sk-digital-v1\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php(373): Illuminate\\Routing\\Router-&gt;loadRoutes(Object(Closure)) #9 </code></pre> </div>

如何检查Guzzle 5的进展情况

<div class="post-text" itemprop="text"> <p>I use Guzzle 5 to get data from api and insert into database. After run this php code I use another ajax call which get's current progress. The problem is that ajax call return value after script finish. So it is always 100%. Is there a way I can get insert progress ?</p> <pre><code> $client = new GuzzleHttp\Client([ 'base_url' =&gt; $domain ]); $params = []; $requests[] = $client-&gt;createRequest('GET', '?' . http_build_query($params)); GuzzleHttp\Pool::send($client, $requests, [ 'pool_size' =&gt; 10, 'complete' =&gt; function (CompleteEvent $event) { $this-&gt;insertData(); } }, 'error' =&gt; function (ErrorEvent $event) { $this-&gt;handleError($error); } ]); </code></pre> <p>It look like database is busy that's why I can't get progress data which I store in database.</p> </div>

Lavel 5.x与Redis Queues生成大量日志

<div class="post-text" itemprop="text"> <p>I have a project that's setup with Laravel and Redis Queues. The application is configured to send push notifications when it receives a message. As soon as message is received, it's stored in the DB and a push is generated:</p> <p><code>dispatch(new CreateMessageNotification($message));</code></p> <p>Project is using Redis queue and Service Provider. The problem is that queue dispatch doesn't work if we don't execute the following command:</p> <p><code>php artisan queue:work redis --daemon</code></p> <p>However, when we do run this command, the application start to generate error logs below. It appears that some routine is stuck somewhere, and we're unable to figure out where, why and how? If we don't run this script, push notifications don't work. If we do run this script, push notifications work with delay, and ERROR logs are produced AND the size of log reaches to GB in a matter of an hour. What are we doing wrong here?</p> <p>We're using Redis/Predis:</p> <pre><code>'redis' =&gt; [ 'client' =&gt; 'predis', 'cluster' =&gt; env('REDIS_CLUSTER', false), 'default' =&gt; [ 'host' =&gt; env('REDIS_HOST', 'localhost'), 'password' =&gt; env('REDIS_PASSWORD', null), 'port' =&gt; env('REDIS_PORT', 6379), 'database' =&gt; env('REDIS_DB', 0), 'timeout' =&gt; 15.0, ], ], </code></pre> <p>For broadcasting, we're using Pusher:</p> <pre><code>'default' =&gt; env('BROADCAST_DRIVER', 'pusher'), </code></pre> <p>For queue, we're using Redis:</p> <pre><code>'default' =&gt; env('QUEUE_DRIVER', 'sync'), QUEUE_DRIVER=redis </code></pre> <p>For cache, we're using Redis:</p> <pre><code>'default' =&gt; env('CACHE_DRIVER', 'file'), CACHE_DRIVER=redis </code></pre> <p><strong>CreateMessageNotification</strong></p> <pre><code>&lt;?php namespace App\Jobs\EventHandlers; use App\Events\Notifications\NewMessageCreatedEvent; use App\Repositories\UserDevicesRepository; use Event; use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Queue\InteractsWithQueue; use Illuminate\Queue\SerializesModels; class CreateMessageNotification implements ShouldQueue { use InteractsWithQueue, Queueable, SerializesModels; private $message; public function __construct($message) { $this-&gt;message = $message; } public function handle() { Event::fire(new NewMessageCreatedEvent($this-&gt;message)); } } </code></pre> <p><strong>NewMessageCreatedEvent</strong></p> <pre><code>&lt;?php namespace App\Events\Notifications; use App\Models\Chat\Message; use Event; use Illuminate\Queue\SerializesModels; class NewMessageCreatedEvent extends Event { use SerializesModels; public function __construct(Message $message) { $message-&gt;load(['other', 'chat', 'chat.chatUsers']); foreach ($message-&gt;chat-&gt;chatUsers as $chatUser) { if ($chatUser-&gt;user_id !== $message-&gt;other-&gt;id) { Event::fire(new NewMessageNotificationEvent($message, $chatUser-&gt;user_id)); } } } } </code></pre> <p><strong>ERROR LOG</strong></p> <pre><code>[2018-09-06 06:28:55] local.ERROR: exception 'Illuminate\Broadcasting\BroadcastException' with message 'API call failed since (daily) message quota exceeded ' in /var/www/html/project/vendor/laravel/framework/src/Illuminate/Broadcasting/Broadcasters/PusherBroadcaster.php:106 Stack trace: #0 /var/www/html/project/vendor/laravel/framework/src/Illuminate/Broadcasting/BroadcastEvent.php(49): Illuminate\Broadcasting\Broadcasters\PusherBroadcaster-&gt;broadcast(Array, 'new_$ #1 [internal function]: Illuminate\Broadcasting\BroadcastEvent-&gt;handle(Object(Illuminate\Broadcasting\Broadcasters\PusherBroadcaster)) #2 /var/www/html/project/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(30): call_user_func_array(Array, Array) #3 /var/www/html/project/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(87): Illuminate\Container\BoundMethod::Illuminate\Container\{closure}() #4 /var/www/html/project/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(31): Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Foundation\Appli$ #5 /var/www/html/project/vendor/laravel/framework/src/Illuminate/Container/Container.php(539): Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Application), Arr$ #6 /var/www/html/project/vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php(94): Illuminate\Container\Container-&gt;call(Array) #7 /var/www/html/project/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(114): Illuminate\Bus\Dispatcher-&gt;Illuminate\Bus\{closure}(Object(Illuminate\Broadcasting\Broa$ #8 /var/www/html/project/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(102): Illuminate\Pipeline\Pipeline-&gt;Illuminate\Pipeline\{closure}(Object(Illuminate\Broadcast$ #9 /var/www/html/project/vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php(98): Illuminate\Pipeline\Pipeline-&gt;then(Object(Closure)) #10 /var/www/html/project/vendor/laravel/framework/src/Illuminate/Queue/CallQueuedHandler.php(43): Illuminate\Bus\Dispatcher-&gt;dispatchNow(Object(Illuminate\Broadcasting\BroadcastEv$ #11 /var/www/html/project/vendor/laravel/framework/src/Illuminate/Queue/Jobs/Job.php(69): Illuminate\Queue\CallQueuedHandler-&gt;call(Object(Illuminate\Queue\Jobs\RedisJob), Array) #12 /var/www/html/project/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(317): Illuminate\Queue\Jobs\Job-&gt;fire() #13 /var/www/html/project/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(267): Illuminate\Queue\Worker-&gt;process('redis', Object(Illuminate\Queue\Jobs\RedisJob), Object(Il$ #14 /var/www/html/project/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(113): Illuminate\Queue\Worker-&gt;runJob(Object(Illuminate\Queue\Jobs\RedisJob), 'redis', Object(Ill$ #15 /var/www/html/project/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(102): Illuminate\Queue\Worker-&gt;daemon('redis', 'default', Object(Illuminate\Queue\Wo$ #16 /var/www/html/project/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(86): Illuminate\Queue\Console\WorkCommand-&gt;runWorker('redis', 'default') #17 [internal function]: Illuminate\Queue\Console\WorkCommand-&gt;fire() #18 /var/www/html/project/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(30): call_user_func_array(Array, Array) #19 /var/www/html/project/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(87): Illuminate\Container\BoundMethod::Illuminate\Container\{closure}() #20 /var/www/html/project/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(31): Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Foundation\Appl$ #21 /var/www/html/project/vendor/laravel/framework/src/Illuminate/Container/Container.php(539): Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Application), Ar$ #22 /var/www/html/project/vendor/laravel/framework/src/Illuminate/Console/Command.php(182): Illuminate\Container\Container-&gt;call(Array) #23 /var/www/html/project/vendor/symfony/console/Command/Command.php(252): Illuminate\Console\Command-&gt;execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\$ #24 /var/www/html/project/vendor/laravel/framework/src/Illuminate/Console/Command.php(168): Symfony\Component\Console\Command\Command-&gt;run(Object(Symfony\Component\Console\Input\Ar$ #25 /var/www/html/project/vendor/symfony/console/Application.php(946): Illuminate\Console\Command-&gt;run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\C$ #26 /var/www/html/project/vendor/symfony/console/Application.php(248): Symfony\Component\Console\Application-&gt;doRunCommand(Object(Illuminate\Queue\Console\WorkCommand), Object(Symf$ #27 /var/www/html/project/vendor/symfony/console/Application.php(148): Symfony\Component\Console\Application-&gt;doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfon$ #28 /var/www/html/project/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(122): Symfony\Component\Console\Application-&gt;run(Object(Symfony\Component\Console\In$ #29 /var/www/html/project/artisan(36): Illuminate\Foundation\Console\Kernel-&gt;handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\Conso$ #30 {main} [2018-09-06 06:28:55] local.ERROR: exception 'ErrorException' with message 'Trying to get property of non-object' in /var/www/html/project/app/Events/Notifications/NewMessageCreate$ Stack trace: #0 /var/www/html/project/app/Events/Notifications/NewMessageCreatedEvent.php(27): Illuminate\Foundation\Bootstrap\HandleExceptions-&gt;handleError(8, 'Trying to get p...', '/var/www/h$ #1 /var/www/html/project/app/Jobs/EventHandlers/CreateMessageNotification.php(38): App\Events\Notifications\NewMessageCreatedEvent-&gt;__construct(Object(App\Models\Chat\Message)) #2 [internal function]: App\Jobs\EventHandlers\CreateMessageNotification-&gt;handle() #3 /var/www/html/project/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(30): call_user_func_array(Array, Array) #4 /var/www/html/project/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(87): Illuminate\Container\BoundMethod::Illuminate\Container\{closure}() #5 /var/www/html/project/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(31): Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Foundation\Appli$ #6 /var/www/html/project/vendor/laravel/framework/src/Illuminate/Container/Container.php(539): Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Application), Arr$ #7 /var/www/html/project/vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php(94): Illuminate\Container\Container-&gt;call(Array) #8 /var/www/html/project/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(114): Illuminate\Bus\Dispatcher-&gt;Illuminate\Bus\{closure}(Object(App\Jobs\EventHandlers\Creat$ #9 /var/www/html/project/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(102): Illuminate\Pipeline\Pipeline-&gt;Illuminate\Pipeline\{closure}(Object(App\Jobs\EventHandle$ #10 /var/www/html/project/vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php(98): Illuminate\Pipeline\Pipeline-&gt;then(Object(Closure)) #11 /var/www/html/project/vendor/laravel/framework/src/Illuminate/Queue/CallQueuedHandler.php(43): Illuminate\Bus\Dispatcher-&gt;dispatchNow(Object(App\Jobs\EventHandlers\CreateMessag$ #12 /var/www/html/project/vendor/laravel/framework/src/Illuminate/Queue/Jobs/Job.php(69): Illuminate\Queue\CallQueuedHandler-&gt;call(Object(Illuminate\Queue\Jobs\RedisJob), Array) #13 /var/www/html/project/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(317): Illuminate\Queue\Jobs\Job-&gt;fire() #14 /var/www/html/project/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(267): Illuminate\Queue\Worker-&gt;process('redis', Object(Illuminate\Queue\Jobs\RedisJob), Object(Il$ #15 /var/www/html/project/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(113): Illuminate\Queue\Worker-&gt;runJob(Object(Illuminate\Queue\Jobs\RedisJob), 'redis', Object(Ill$ #16 /var/www/html/project/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(102): Illuminate\Queue\Worker-&gt;daemon('redis', 'default', Object(Illuminate\Queue\Wo$ #17 /var/www/html/project/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(86): Illuminate\Queue\Console\WorkCommand-&gt;runWorker('redis', 'default') #18 [internal function]: Illuminate\Queue\Console\WorkCommand-&gt;fire() #19 /var/www/html/project/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(30): call_user_func_array(Array, Array) #20 /var/www/html/project/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(87): Illuminate\Container\BoundMethod::Illuminate\Container\{closure}() #21 /var/www/html/project/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(31): Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Foundation\Appl$ #22 /var/www/html/project/vendor/laravel/framework/src/Illuminate/Container/Container.php(539): Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Application), Ar$ #23 /var/www/html/project/vendor/laravel/framework/src/Illuminate/Console/Command.php(182): Illuminate\Container\Container-&gt;call(Array) #24 /var/www/html/project/vendor/symfony/console/Command/Command.php(252): Illuminate\Console\Command-&gt;execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\$ #25 /var/www/html/project/vendor/laravel/framework/src/Illuminate/Console/Command.php(168): Symfony\Component\Console\Command\Command-&gt;run(Object(Symfony\Component\Console\Input\Ar$ #26 /var/www/html/project/vendor/symfony/console/Application.php(946): Illuminate\Console\Command-&gt;run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\C$ #27 /var/www/html/project/vendor/symfony/console/Application.php(248): Symfony\Component\Console\Application-&gt;doRunCommand(Object(Illuminate\Queue\Console\WorkCommand), Object(Symf$ #28 /var/www/html/project/vendor/symfony/console/Application.php(148): Symfony\Component\Console\Application-&gt;doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfon$ #29 /var/www/html/project/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(122): Symfony\Component\Console\Application-&gt;run(Object(Symfony\Component\Console\In$ #30 /var/www/html/project/artisan(36): Illuminate\Foundation\Console\Kernel-&gt;handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\Conso$ </code></pre> </div>

在中国程序员是青春饭吗?

今年,我也32了 ,为了不给大家误导,咨询了猎头、圈内好友,以及年过35岁的几位老程序员……舍了老脸去揭人家伤疤……希望能给大家以帮助,记得帮我点赞哦。 目录: 你以为的人生 一次又一次的伤害 猎头界的真相 如何应对互联网行业的「中年危机」 一、你以为的人生 刚入行时,拿着傲人的工资,想着好好干,以为我们的人生是这样的: 等真到了那一天,你会发现,你的人生很可能是这样的: ...

程序员请照顾好自己,周末病魔差点一套带走我。

程序员在一个周末的时间,得了重病,差点当场去世,还好及时挽救回来了。

和黑客斗争的 6 天!

互联网公司工作,很难避免不和黑客们打交道,我呆过的两家互联网公司,几乎每月每天每分钟都有黑客在公司网站上扫描。有的是寻找 Sql 注入的缺口,有的是寻找线上服务器可能存在的漏洞,大部分都...

搜狗输入法也在挑战国人的智商!

故事总是一个接着一个到来...上周写完《鲁大师已经彻底沦为一款垃圾流氓软件!》这篇文章之后,鲁大师的市场工作人员就找到了我,希望把这篇文章删除掉。经过一番沟通我先把这篇文章从公号中删除了...

总结了 150 余个神奇网站,你不来瞅瞅吗?

原博客再更新,可能就没了,之后将持续更新本篇博客。

副业收入是我做程序媛的3倍,工作外的B面人生是怎样的?

提到“程序员”,多数人脑海里首先想到的大约是:为人木讷、薪水超高、工作枯燥…… 然而,当离开工作岗位,撕去层层标签,脱下“程序员”这身外套,有的人生动又有趣,马上展现出了完全不同的A/B面人生! 不论是简单的爱好,还是正经的副业,他们都干得同样出色。偶尔,还能和程序员的特质结合,产生奇妙的“化学反应”。 @Charlotte:平日素颜示人,周末美妆博主 大家都以为程序媛也个个不修边幅,但我们也许...

MySQL数据库面试题(2020最新版)

文章目录数据库基础知识为什么要使用数据库什么是SQL?什么是MySQL?数据库三大范式是什么mysql有关权限的表都有哪几个MySQL的binlog有有几种录入格式?分别有什么区别?数据类型mysql有哪些数据类型引擎MySQL存储引擎MyISAM与InnoDB区别MyISAM索引与InnoDB索引的区别?InnoDB引擎的4大特性存储引擎选择索引什么是索引?索引有哪些优缺点?索引使用场景(重点)...

如果你是老板,你会不会踢了这样的员工?

有个好朋友ZS,是技术总监,昨天问我:“有一个老下属,跟了我很多年,做事勤勤恳恳,主动性也很好。但随着公司的发展,他的进步速度,跟不上团队的步伐了,有点...

我入职阿里后,才知道原来简历这么写

私下里,有不少读者问我:“二哥,如何才能写出一份专业的技术简历呢?我总感觉自己写的简历太烂了,所以投了无数份,都石沉大海了。”说实话,我自己好多年没有写过简历了,但我认识的一个同行,他在阿里,给我说了一些他当年写简历的方法论,我感觉太牛逼了,实在是忍不住,就分享了出来,希望能够帮助到你。 01、简历的本质 作为简历的撰写者,你必须要搞清楚一点,简历的本质是什么,它就是为了来销售你的价值主张的。往深...

优雅的替换if-else语句

场景 日常开发,if-else语句写的不少吧??当逻辑分支非常多的时候,if-else套了一层又一层,虽然业务功能倒是实现了,但是看起来是真的很不优雅,尤其是对于我这种有强迫症的程序"猿",看到这么多if-else,脑袋瓜子就嗡嗡的,总想着解锁新姿势:干掉过多的if-else!!!本文将介绍三板斧手段: 优先判断条件,条件不满足的,逻辑及时中断返回; 采用策略模式+工厂模式; 结合注解,锦...

离职半年了,老东家又发 offer,回不回?

有小伙伴问松哥这个问题,他在上海某公司,在离职了几个月后,前公司的领导联系到他,希望他能够返聘回去,他很纠结要不要回去? 俗话说好马不吃回头草,但是这个小伙伴既然感到纠结了,我觉得至少说明了两个问题:1.曾经的公司还不错;2.现在的日子也不是很如意。否则应该就不会纠结了。 老实说,松哥之前也有过类似的经历,今天就来和小伙伴们聊聊回头草到底吃不吃。 首先一个基本观点,就是离职了也没必要和老东家弄的苦...

2020阿里全球数学大赛:3万名高手、4道题、2天2夜未交卷

阿里巴巴全球数学竞赛( Alibaba Global Mathematics Competition)由马云发起,由中国科学技术协会、阿里巴巴基金会、阿里巴巴达摩院共同举办。大赛不设报名门槛,全世界爱好数学的人都可参与,不论是否出身数学专业、是否投身数学研究。 2020年阿里巴巴达摩院邀请北京大学、剑桥大学、浙江大学等高校的顶尖数学教师组建了出题组。中科院院士、美国艺术与科学院院士、北京国际数学...

男生更看重女生的身材脸蛋,还是思想?

往往,我们看不进去大段大段的逻辑。深刻的哲理,往往短而精悍,一阵见血。问:产品经理挺漂亮的,有点心动,但不知道合不合得来。男生更看重女生的身材脸蛋,还是...

程序员为什么千万不要瞎努力?

本文作者用对比非常鲜明的两个开发团队的故事,讲解了敏捷开发之道 —— 如果你的团队缺乏统一标准的环境,那么即使勤劳努力,不仅会极其耗时而且成果甚微,使用...

为什么程序员做外包会被瞧不起?

二哥,有个事想询问下您的意见,您觉得应届生值得去外包吗?公司虽然挺大的,中xx,但待遇感觉挺低,马上要报到,挺纠结的。

当HR压你价,说你只值7K,你该怎么回答?

当HR压你价,说你只值7K时,你可以流畅地回答,记住,是流畅,不能犹豫。 礼貌地说:“7K是吗?了解了。嗯~其实我对贵司的面试官印象很好。只不过,现在我的手头上已经有一份11K的offer。来面试,主要也是自己对贵司挺有兴趣的,所以过来看看……”(未完) 这段话主要是陪HR互诈的同时,从公司兴趣,公司职员印象上,都给予对方正面的肯定,既能提升HR的好感度,又能让谈判气氛融洽,为后面的发挥留足空间。...

面试:第十六章:Java中级开发(16k)

HashMap底层实现原理,红黑树,B+树,B树的结构原理 Spring的AOP和IOC是什么?它们常见的使用场景有哪些?Spring事务,事务的属性,传播行为,数据库隔离级别 Spring和SpringMVC,MyBatis以及SpringBoot的注解分别有哪些?SpringMVC的工作原理,SpringBoot框架的优点,MyBatis框架的优点 SpringCould组件有哪些,他们...

面试阿里p7,被按在地上摩擦,鬼知道我经历了什么?

面试阿里p7被问到的问题(当时我只知道第一个):@Conditional是做什么的?@Conditional多个条件是什么逻辑关系?条件判断在什么时候执...

面试了一个 31 岁程序员,让我有所触动,30岁以上的程序员该何去何从?

最近面试了一个31岁8年经验的程序猿,让我有点感慨,大龄程序猿该何去何从。

大三实习生,字节跳动面经分享,已拿Offer

说实话,自己的算法,我一个不会,太难了吧

程序员垃圾简历长什么样?

已经连续五年参加大厂校招、社招的技术面试工作,简历看的不下于万份 这篇文章会用实例告诉你,什么是差的程序员简历! 疫情快要结束了,各个公司也都开始春招了,作为即将红遍大江南北的新晋UP主,那当然要为小伙伴们做点事(手动狗头)。 就在公众号里公开征简历,义务帮大家看,并一一点评。《启舰:春招在即,义务帮大家看看简历吧》 一石激起千层浪,三天收到两百多封简历。 花光了两个星期的所有空闲时...

《Oracle Java SE编程自学与面试指南》最佳学习路线图2020年最新版(进大厂必备)

正确选择比瞎努力更重要!

《Oracle Java SE编程自学与面试指南》最佳学习路线图(2020最新版)

正确选择比瞎努力更重要!

都前后端分离了,咱就别做页面跳转了!统统 JSON 交互

文章目录1. 无状态登录1.1 什么是有状态1.2 什么是无状态1.3 如何实现无状态1.4 各自优缺点2. 登录交互2.1 前后端分离的数据交互2.2 登录成功2.3 登录失败3. 未认证处理方案4. 注销登录 这是本系列的第四篇,有小伙伴找不到之前文章,松哥给大家列一个索引出来: 挖一个大坑,Spring Security 开搞! 松哥手把手带你入门 Spring Security,别再问密...

字节跳动面试官竟然问了我JDBC?

轻松等回家通知

面试官:你连SSO都不懂,就别来面试了

大厂竟然要考我SSO,卧槽。

阿里面试官让我用Zk(Zookeeper)实现分布式锁

他可能没想到,我当场手写出来了

终于,月薪过5万了!

来看几个问题想不想月薪超过5万?想不想进入公司架构组?想不想成为项目组的负责人?想不想成为spring的高手,超越99%的对手?那么本文内容是你必须要掌握的。本文主要详解bean的生命...

自从喜欢上了B站这12个UP主,我越来越觉得自己是个废柴了!

不怕告诉你,我自从喜欢上了这12个UP主,哔哩哔哩成为了我手机上最耗电的软件,几乎每天都会看,可是吧,看的越多,我就越觉得自己是个废柴,唉,老天不公啊,不信你看看…… 间接性踌躇满志,持续性混吃等死,都是因为你们……但是,自己的学习力在慢慢变强,这是不容忽视的,推荐给你们! 都说B站是个宝,可是有人不会挖啊,没事,今天咱挖好的送你一箩筐,首先啊,我在B站上最喜欢看这个家伙的视频了,为啥 ,咱撇...

代码注释如此沙雕,会玩还是你们程序员!

某站后端代码被“开源”,同时刷遍全网的,还有代码里的那些神注释。 我们这才知道,原来程序员个个都是段子手;这么多年来,我们也走过了他们的无数套路… 首先,产品经理,是永远永远吐槽不完的!网友的评论也非常扎心,说看这些代码就像在阅读程序员的日记,每一页都写满了对产品经理的恨。 然后,也要发出直击灵魂的质问:你是尊贵的付费大会员吗? 这不禁让人想起之前某音乐app的穷逼Vip,果然,穷逼在哪里都是...

2020春招面试了10多家大厂,我把问烂了的数据库事务知识点总结了一下

2020年截止目前,我面试了阿里巴巴、腾讯、美团、拼多多、京东、快手等互联网大厂。我发现数据库事务在面试中出现的次数非常多。

爬虫(101)爬点重口味的

小弟最近在学校无聊的很哪,浏览网页突然看到一张图片,都快流鼻血。。。然后小弟冥思苦想,得干一点有趣的事情python 爬虫库安装https://s.taobao.com/api?_ks...

在拼多多上班,是一种什么样的体验?我心态崩了呀!

之前有很多读者咨询我:武哥,在拼多多上班是一种什么样的体验?由于一直很忙,没抽出时间来和大家分享。上周末特地花点时间来写了一篇文章,跟大家分享一下拼多多的日常。 1. 倒时差的作息 可能很多小伙伴都听说了,拼多多加班很严重。这怎么说呢?作息上确实和其他公司有点区别,大家知道 996,那么自然也就能理解拼多多的“11 11 6”了。 所以当很多小伙伴早上出门时,他们是这样的: 我们是这样的: 当...

应聘3万的职位,有必要这么刁难我么。。。沙雕。。。

又一次被面试官带到坑里面了。面试官:springmvc用过么?我:用过啊,经常用呢面试官:springmvc中为什么需要用父子容器?我:嗯。。。没听明白你说的什么。面试官:就是contr...

太狠了,疫情期间面试,一个问题砍了我5000!

疫情期间找工作确实有点难度,想拿到满意的薪资,确实要点实力啊!面试官:Spring中的@Value用过么,介绍一下我:@Value可以标注在字段上面,可以将外部配置文件中的数据,比如可以...

自学编程的 6 个致命误区

嗨,小伙伴们大家好,我是沉默王二。本篇文章来和大家聊聊自学编程中的一些误区——这是我在 B 站上看了羊哥的一期视频后有感而发的文章。因为确实有很多读者也曾私信问过我这些方面的问题,很有代表性,所以我就结合自己的亲身体会来谈一谈,希望对小伙伴们有所启发。 01、追求时髦 所谓基础不牢,地动山摇啊。可很多小伙伴压根就没注意过这个问题,市面上出什么新鲜的技术就想去尝试,结果把自己学的乱七八糟,心灰意冷...

漫画:什么是 “眼镜蛇效应” ?

世界是复杂的。每当你做出一个决定的时候,你的出发点通常是好的,但结果一定会好吗?在印度的某个地区,当地野生的眼镜蛇非常泛滥。众所周知,眼镜蛇有剧毒,又具有很强的攻击性,给当地居民的生命安...

立即提问
相关内容推荐