Jump to content

help with query.


seany123

Recommended Posts

$query = $db->execute("select `msg`, `status` from `user_log` where `player_id`=? AND `status` = 'unread' AND `status` = 'read' order by `status` desc", array($player->id));

You should post SQL questions in the SQL forum.

 

yeah im sorry, it seemed to work here though ;)

 

 

ill give it a try thanks

Link to comment
https://forums.phpfreaks.com/topic/156571-help-with-query/#findComment-824390
Share on other sites

If im not mistaken but status cannot equal read and unread at the same time. Your query should be

$query = $db->execute("select `msg`, `status` from `user_log` where AND `player_id`=? AND `status` = 'read' OR `status` = 'unread' order by `status` desc", array($player->id));

 

Link to comment
https://forums.phpfreaks.com/topic/156571-help-with-query/#findComment-824392
Share on other sites

okay i now tested this out but got a error...

 

Fatal error: Call to a member function on a non-object on line 31

 

 

line 31 is...

 

if ($query->recordcount() > 0)

 

 

 

this is the entire page..

 

<?php
include("lib.php");
define("PAGENAME", "Log");
$player = check_user($secret_key, $db);

include("templates/private_header3.php");

if ($_GET['act'] == "clear")
{
    //Clear all log messages for current user
    $query = $db->execute("update `user_log` set `status`='deleted' where `player_id`=? and `status`='read' or `status`='unread'", array($player->id));
}

//Get all log messages ordered by status
$query = $db->execute("select `msg`, `status` from `user_log` where AND `player_id`=? AND `status` = 'read' OR `status` = 'unread' order by `status` desc", array($player->id));

//Update the status of the messages because now they have been read
$query2 = $db->execute("update `user_log` set `status`='read' where `player_id`=? and `status`='unread'", array($player->id));
?>
      
<html>
<head>
<title>Mafiakiller</title>
<link rel="stylesheet" href="/css/style.css" type="text/css" media="all" />
</head>
<body alink="#cc9900" vlink="#cc9900" link="#cc9900">
<div id="holder">
<div id="left_c"><div class="g_content"><h3>  Events</h3><div class="g_text"><table width='100%'>

<?php
if ($query->recordcount() > 0)
{
    echo "<a href=\"log.php?act=clear\">Clear log</a>";
    while ($log = $query->fetchrow())
    {
        echo "<fieldset>\n";
        echo "<legend>";
        echo ($log['status']=="unread")?"<b>" . ucwords($log['status']) .   "</b>":ucwords($log['status']);
        echo "</legend>\n";
        echo $log['msg'] . "\n";
        echo "</fieldset>\n<br />\n";
    }
}
else
{
    echo "No log messages!";
}

?>
</div>
</div>
</div>
</div>
</body>
</html>    

Link to comment
https://forums.phpfreaks.com/topic/156571-help-with-query/#findComment-824399
Share on other sites

well this worked fine when i had...

 

 

<?php
if ($_GET['act'] == "clear")
{
    //Clear all log messages for current user
    $query = $db->execute("delete from `user_log` where `player_id`=?", array($player->id));
}

//Get all log messages ordered by status
$query = $db->execute("select `msg`, `status` from `user_log` where `player_id`=? order by `status` desc", array($player->id));

 

but now ives changed it to this its not working and giving that error.

 

<?php
if ($_GET['act'] == "clear")
{
    //Clear all log messages for current user
    $query = $db->execute("update `user_log` set `status`='deleted' where `player_id`=? and `status`='read' or `status`='unread'", array($player->id));
}

//Get all log messages ordered by status
$query = $db->execute("select `msg`, `status` from `user_log` where AND `player_id`=? AND `status` = 'read' OR `status` = 'unread' order by `status` desc", array($player->id));

Link to comment
https://forums.phpfreaks.com/topic/156571-help-with-query/#findComment-824414
Share on other sites

this...

 

 

$db = &ADONewConnection('mysql'); //Connect to database

$db->Connect($config_server, $config_username, $config_password, $config_database); //Select table

 

$db->SetFetchMode(ADODB_FETCH_ASSOC); //Fetch associative arrays

$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC; //Fetch associative arrays

//$db->debug = true; //Debug

 

Link to comment
https://forums.phpfreaks.com/topic/156571-help-with-query/#findComment-824454
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.