Fatal error: Call to a member function prepare() on a non-object.
I have a problem when i enter login details i get this error
Fatal error: Call to a member function prepare() on a non-object in
C:\wamp\www\Remake Login Page\Classes\Mysql.php on line 22
Code of Mysql.php:
<?php
require_once 'includes/constants.php';
class Mysql {
private $conn;
function _construct() {
$this->$conn = new mysqli(DB_SERVER, DB_USER, DB_PASSWORD, DB_NAME) or
die
('There was a problem connecting to the database');
}
function verify_Username_and_Pass($un, $pwd) {
$query = "SELECT *
FROM users
WHERE username = ? AND password = ?
LIMIT 1";
if($stmt = $this->conn->prepare($query)) {
$stmt->bind_param('ss', $un, $pwd);
$stmt->execute();
if($stmt->fetch()) {
$stmt->close();
return true;
}
}
}
}
Hope someone can help me.
Thanks in advance.
Busser
Sunday, 1 September 2013
Saturday, 31 August 2013
Insert array in one insert query
Insert array in one insert query
i need use on array in insert query :
SET @follower = (SELECT follow.follower FROM follow WHERE
following=NEW.user_id);
INSERT INTO followRead (`id_fk`, `follower`, `seen`) VALUES (NEW.id,
implode(",",@follower) , 0);
in this query used from implode function
i need use on array in insert query :
SET @follower = (SELECT follow.follower FROM follow WHERE
following=NEW.user_id);
INSERT INTO followRead (`id_fk`, `follower`, `seen`) VALUES (NEW.id,
implode(",",@follower) , 0);
in this query used from implode function
Multiple channel's message comes into single channel
Multiple channel's message comes into single channel
i am fresher of Spring Integration, i am confuing one question which i
have multiple channels but now i want to assemble messages from those
channel into single channel, how to implement it ? my senario is that i
have lots of businees modues and each module will corresponding to one
channel, those channels will receive the request then assemble the message
into one single channel , then output to the jms server:
is below code possible ?
<channel id='a'/> <bridge input-channel='a' out-channel='assembled'/>
<channel id='b'/> <bridge input-channel='b' out-channel='assembled'/>
<channel id='b'/> <bridge input-channel='c' out-channel='assembled'/>
<channel id='c'/> <bridge input-channel='d' out-channel='assembled'/>
<channel id='assembled'/>
<!-- the router will desicde which jms gateway to be sent -->
<router input-channel='assembled' >
<channel id='to_jms1'/>
<channel id='to_jms2'/>
<jms-outbound-gateway id='jms1' channel='to_jms1'/>
<jms-outbound-gateway id='jms2' channel='to_jms2'/>
i am fresher of Spring Integration, i am confuing one question which i
have multiple channels but now i want to assemble messages from those
channel into single channel, how to implement it ? my senario is that i
have lots of businees modues and each module will corresponding to one
channel, those channels will receive the request then assemble the message
into one single channel , then output to the jms server:
is below code possible ?
<channel id='a'/> <bridge input-channel='a' out-channel='assembled'/>
<channel id='b'/> <bridge input-channel='b' out-channel='assembled'/>
<channel id='b'/> <bridge input-channel='c' out-channel='assembled'/>
<channel id='c'/> <bridge input-channel='d' out-channel='assembled'/>
<channel id='assembled'/>
<!-- the router will desicde which jms gateway to be sent -->
<router input-channel='assembled' >
<channel id='to_jms1'/>
<channel id='to_jms2'/>
<jms-outbound-gateway id='jms1' channel='to_jms1'/>
<jms-outbound-gateway id='jms2' channel='to_jms2'/>
Ruby script hanging
Ruby script hanging
I've spent a ridiculous amount of time trying to figure out why this is
hanging. I'm assuming it has something to do with the way I've formatted
my || for the "if" statement.
rods = {
:rod1 => [3,2,1],
:rod2 => [],
:rod3 => []
}
init_rod = gets.chomp.to_sym
if ((init_rod != :rod1 || init_rod != :rod2) || init_rod != :rod3)
print "Type in \"rod1\", \"rod2\", or \"rod3\": "
elsif rods[init_rod].empty?
print "Rod has no discs. Select another rod other than #{init_rod}: "
else
disc = rods[init_rod].pop
end
I've spent a ridiculous amount of time trying to figure out why this is
hanging. I'm assuming it has something to do with the way I've formatted
my || for the "if" statement.
rods = {
:rod1 => [3,2,1],
:rod2 => [],
:rod3 => []
}
init_rod = gets.chomp.to_sym
if ((init_rod != :rod1 || init_rod != :rod2) || init_rod != :rod3)
print "Type in \"rod1\", \"rod2\", or \"rod3\": "
elsif rods[init_rod].empty?
print "Rod has no discs. Select another rod other than #{init_rod}: "
else
disc = rods[init_rod].pop
end
Bytes message argument error
Bytes message argument error
I can't figure out what the 'bytes' method is complaining about. In the
code below, i am trying to generate an authentication key for my client
and i keep getting this error [1]
import hmac
import hashlib
import base64
message = bytes("Message", 'utf-8') # errors here
secret = bytes("secret", 'utf-8')
signature = base64.b64encode(hmac.new(secret, message,
digestmod=hashlib.sha256).digest());
print(signature)
[1]
Traceback (most recent call last):
File "API/test/auth-client.py", line 11, in <module>
message = bytes("Message", 'utf-8')
TypeError: str() takes at most 1 argument (2 given)
I can't figure out what the 'bytes' method is complaining about. In the
code below, i am trying to generate an authentication key for my client
and i keep getting this error [1]
import hmac
import hashlib
import base64
message = bytes("Message", 'utf-8') # errors here
secret = bytes("secret", 'utf-8')
signature = base64.b64encode(hmac.new(secret, message,
digestmod=hashlib.sha256).digest());
print(signature)
[1]
Traceback (most recent call last):
File "API/test/auth-client.py", line 11, in <module>
message = bytes("Message", 'utf-8')
TypeError: str() takes at most 1 argument (2 given)
Modify pointer through void**
Modify pointer through void**
Is it legal to access a pointer type through a void **?
I've looked over the standards quotes on pointer aliasing but I'm still
unsure on whether this is legal C or not:
int *array;
void ** vp = (void**)&array;
*vp = malloc(sizeof(int)*10);
Trivial example, but it applies to a more complex situation I'm seeing.
It seems that it wouldn't be legal since I'm accessing an int * through a
type not an int * or char *. I can't come to a simple conclusion on this.
Is it legal to access a pointer type through a void **?
I've looked over the standards quotes on pointer aliasing but I'm still
unsure on whether this is legal C or not:
int *array;
void ** vp = (void**)&array;
*vp = malloc(sizeof(int)*10);
Trivial example, but it applies to a more complex situation I'm seeing.
It seems that it wouldn't be legal since I'm accessing an int * through a
type not an int * or char *. I can't come to a simple conclusion on this.
C# I need a algorithmic for Lock-by-value
C# I need a algorithmic for Lock-by-value
You have a function Foo(long x) which is called by many threads. You want
to prevent threads from executing the method simultaneously for the same
value of x. If two methods call it with x=10, one should block and wait
for the other to finish; but if one thread calls it with x=10 and another
with x=11, they should run in parallel. X can be any long value. You must
not keep in memory all the values with which the function was called in
the past, but free them once all threads with that value exit the function
(you may wait for GC to free them). Extra: if two threads, with different
values of X, do not contend for any shared lock (such as a static
management lock) when entering or leaving the function, and only threads
with the same values of X can ever block and wait.
You have a function Foo(long x) which is called by many threads. You want
to prevent threads from executing the method simultaneously for the same
value of x. If two methods call it with x=10, one should block and wait
for the other to finish; but if one thread calls it with x=10 and another
with x=11, they should run in parallel. X can be any long value. You must
not keep in memory all the values with which the function was called in
the past, but free them once all threads with that value exit the function
(you may wait for GC to free them). Extra: if two threads, with different
values of X, do not contend for any shared lock (such as a static
management lock) when entering or leaving the function, and only threads
with the same values of X can ever block and wait.
Subscribe to:
Comments (Atom)