我有DreamHost托管的website。子域" fakestore"有一个数据库,因此有一个访问该数据库的脚本。但是,我无法使该数据库工作。我尝试将$servername
更改为127.0.0.1
和aashishbharadwaj.com
。如果我使用localhost,则会收到错误It no work!SQLSTATE[HY000] [2002] No such file or directory
。如果我使用其他两个,我会得到It no work!SQLSTATE[HY000] [2002] Connection refused
。
<?php
$servername = 'localhost'; //I've tried numerous things here, with different errors
//For my server
$username = "username"; //Not actual username
$password = "password"; //Not actual password
$dbname = 'database_name'; //Not actual database name
try {
$db = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
} catch (PDOException $e) {
$error_message = $e->getMessage();
echo "It no work!";
echo $error_message;
exit();
}
?>
答案 0 :(得分:0)
如果您想使用handleclick(digit) {
if (this.state.showingTemporaryResult) {
//console.log("TRUE CALLED");
this.setState({
value: String(digit),
showingTemporaryResult: false
})
} else {
console.log("ELSE CALLED");
this.setState({
value: this.state.value === '0' ? String(digit) : this.state.value + digit
});
}
// console.log('helo click fire',this.state.value);
}
operation(operator) {
console.log('operator coming', operator);
if (operator === '+') {
// this.setState({operation:operator},()=>{console.log('setting immidiate state',this.state.operation)});
if (this.state.operation === '+') {
console.log("are u coming");
let secondValue = parseInt(this.state.value);
let firstValue = parseInt(this.state.firstValue);
console.log('chcking first value ', firstValue);
console.log('chcking second value ', secondValue);
let sum = secondValue + firstValue;
console.log('chcking sum value ', sum);
this.setState({
firstValue: sum,
value: sum,
secondValue: '',
showingTemporaryResult: true
},
() => {
console.log('first', this.state.firstValue, 'second', this.state.secondValue,
'value===', this.state.value)
});
//console.log('somthing here ');
} else if (this.state.operation === '-') {
console.log("something coming");
let secondValue = parseInt(this.state.value);
let firstValue = parseInt(this.state.firstValue);
console.log('chcking first value ', firstValue);
console.log('chcking second value ', secondValue);
let subanswer = secondValue - firstValue;
console.log('chcking sum value ', subanswer);
this.setState({
firstValue: subanswer,
value: subanswer,
secondValue: '',
showingTemporaryResult: true
},
() => {
console.log('first', this.state.firstValue, 'second', this.state.secondValue,
'value===', this.state.value)
});
//console.log('somthing here ');
} else if (this.state.operation === '') {
let firstValue = parseInt(this.state.value);
this.setState({
firstValue
});;
this.setState({
value: '',
operation: operator
});
// console.log('or here ');
}
} else if (operator === '=') {
if (this.state.counter > 0) {
let answer = parseInt(this.state.newAnswere) + parseInt(this.state.value);
console.log('equal operator counter called', this.state.newAnswere, 'value', this.state.value);
this.setState({
value: answer
});
console.log("what is thhis value", this.state.value)
} else if (this.state.operation === '+') {
let answer = parseInt(this.state.value) + parseInt(this.state.firstValue);
console.log('firstvalue', this.state.firstValue)
console.log('value', this.state.value)
console.log('answere', answer)
this.setState({
value: answer
});
this.setState({
counter: 1,
newAnswere: answer
}, () => {
console.log('newcounter', this.state.counter, 'newans', this.state.newAnswere)
})
console.log('value=', this.state.value)
}
}
}
,请阅读https://stackoverflow.com/a/1819767/5920627