2013-12-06, 07:04 PM
Pages: 1 2
2013-12-06, 07:15 PM
$uid1 = 3; // Sender's user id
$uid2 = 45; // Receiver's user id
$query = "SELECT `dateline` from `mybb_privatemessages` WHERE `uid` = '$uid1' AND `toid` = '$uid2';";
If you want the latest one only then:
$query = "SELECT `dateline` from `mybb_privatemessages` WHERE `uid` = '$uid1' AND `toid` = '$uid2' ORDER BY `dateline` DESC LIMIT 1;";
2013-12-06, 07:29 PM
(2013-12-06, 07:15 PM)effone Wrote: [ -> ]$uid1 = 3; // Sender's user id $uid2 = 45; // Receiver's user id $query = "SELECT `dateline` from `mybb_privatemessages` WHERE `uid` = '$uid1' AND `toid` = '$uid2';";
If you want the latest one only then:
$query = "SELECT `dateline` from `mybb_privatemessages` WHERE `uid` = '$uid1' AND `toid` = '$uid2' ORDER BY `dateline` DESC LIMIT 1;";
that doesn't work.
I replaced $uid1 and $uid2 with the sender and receiver uid.
2013-12-06, 09:29 PM
Is there any error you are getting?
Is your DB table prefix 'mybb_' ?
Is your DB table prefix 'mybb_' ?
2013-12-07, 04:43 AM
(2013-12-06, 09:29 PM)effone Wrote: [ -> ]Is there any error you are getting?
Is your DB table prefix 'mybb_' ?
yes, the prefix is mybb_
#1064 - 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 '$query = "SELECT `dateline` from `mybb_privatemessages` WHERE `uid` = '321' AND ' at line 1
here's the query I'm running:
$query = "SELECT `dateline` from `mybb_privatemessages` WHERE `uid` = '321' AND `toid` = '4';";
2013-12-07, 04:53 AM
there is a typo
$query = "SELECT `dateline` from `mybb_privatemessages` WHERE `uid` = '321' AND `toid` = '4'";
2013-12-07, 05:01 AM
Well, if you are using this in a plugin of MyBB; try doing this way:
It should work.
If you are talking about the query terminator then as much I know the semicolon character is a statement terminator and it is a part of the ANSI SQL-92 standard. Though it is optional for single SQL queries.
I placed two terminators one for SQL and other for PHP.
$uid1 = 3; // Sender's user id
$uid2 = 45; // Receiver's user id
$query = $db->query("SELECT dateline FROM ".TABLE_PREFIX."privatemessages WHERE fromid='".$uid1."' AND toid='".$uid2."'");
while($time_stp = $db->fetch_array($query)){
// Do something here ...
print_r($time_stp);
}
It should work.
(2013-12-07, 04:53 AM).m. Wrote: [ -> ]there is a typo
$query = "SELECT `dateline` from `mybb_privatemessages` WHERE `uid` = '321' AND `toid` = '4'";
If you are talking about the query terminator then as much I know the semicolon character is a statement terminator and it is a part of the ANSI SQL-92 standard. Though it is optional for single SQL queries.
I placed two terminators one for SQL and other for PHP.
2013-12-07, 05:13 AM
(2013-12-07, 04:53 AM).m. Wrote: [ -> ]there is a typo
$query = "SELECT `dateline` from `mybb_privatemessages` WHERE `uid` = '321' AND `toid` = '4'";
still a bad query:
#1064 - 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 '$query = "SELECT `dateline` from `mybb_privatemessages` WHERE `uid` = '321' AND ' at line 1
I figured it out by running this:
SELECT `dateline` from `mybb_privatemessages` WHERE `uid` = '321' AND `toid` = '4'
I guess the original problem was the assumption that I was wanting to get the data via a plugin rather than running a query in mysql..
anyhow, thanks all!
2013-12-07, 05:20 AM
Check again, I guess 'uid' should be 'fromid'.
Also, are you sure about marking the correct answer?
Also, are you sure about marking the correct answer?
2013-12-07, 05:25 AM
(2013-12-07, 05:20 AM)effone Wrote: [ -> ]Check again, I guess 'uid' should be 'fromid'.
Also, are you sure about marking the correct answer?
I unmarked it as it is technically wrong.
this was the correct query in mysql:
SELECT `dateline` from `mybb_privatemessages` WHERE `uid` = '321' AND `toid` = '4'
Pages: 1 2