Jump to content

Recommended Posts

When I view the page 'editHistory', the function is this:

function editHistroy($DOGID)
{
    $response ="";
    $count = performSQLMultiRow("select firstname, lastname, logentry, changeDate from editHistory left join useraccounts on editHistory.uid = useraccounts.uid  where keyValue = $DOGID AND tableName='DOG'",$result);

    /* Old query

    "select firstname, lastname, logentry, changeDate from editHistory,useraccounts where keyValue = $DOGID AND tableName='DOG' AND editHistory.uid = useraccounts.uid"

    */

    for($i =0;$i <  $count ; $i++)
    {
        $editHistory = mysql_fetch_array($result);
        if ($editHistory['firstname'] == NULL) {
              $response .= "Unknown";
	}
        else {
            $response .= $editHistory['firstname'];
	}

        if ($editHistory['lastname'] != "NULL") {
              $response .= " " . $editHistory['lastname'];
	}
        $response .= " on " . $editHistory['changeDate'] ." made change <br><span class=fontsize1emnormalPROFILEIndented>'" . $editHistory['logentry'] .  "'</span><br><br>";
    }
    return $response;
}

 

It returns this

Michelle Kramer on 2008-06-01 11:20:22 made change
'Removed All Owners for Dogs for 39804'

Michelle Kramer on 2008-06-01 11:20:22 made change
'Added Owners for 39804'

Michelle Kramer on 2008-06-01 11:20:22 made change
'Updated with RegisteredName='Michelle\'s Test Dog', Alias=NULL, CallName=NULL, AKC=NULL, AKCStudBookYear=NULL, AKCStudBookMonth=NULL, CKC=NULL, CKCStudBookYear=NULL, CKCStudBookMonth=NULL, OtherRegistration=NULL, OtherRegistrationCountry=5, Sex='M', Genotype=2, Colour=2, Dentition=1, Height=NULL, Length=NULL, AdultWeight=NULL, DNAprofile=NULL, BirthCountry=3, CauseOfDeath=NULL, birthYear=2008, birthMonth=5, birthDay=30, deathYear=NULL, deathMonth=NULL, deathDay=NULL, confirmedCauseOfDeath='Unknown', SireID=NULL, damID=NULL, namePrefix=NULL, nameSuffix=NULL, publication1=' ', publication2=' ', publication3=' ''

 

How do I get it so that it does not show any of this?

Michelle Kramer on 2008-06-01 11:20:22 made change
'Updated with RegisteredName='Michelle\'s Test Dog', Alias=NULL, CallName=NULL, AKC=NULL, AKCStudBookYear=NULL, AKCStudBookMonth=NULL, CKC=NULL, CKCStudBookYear=NULL, CKCStudBookMonth=NULL, OtherRegistration=NULL, OtherRegistrationCountry=5, Sex='M', Genotype=2, Colour=2, Dentition=1, Height=NULL, Length=NULL, AdultWeight=NULL, DNAprofile=NULL, BirthCountry=3, CauseOfDeath=NULL, birthYear=2008, birthMonth=5, birthDay=30, deathYear=NULL, deathMonth=NULL, deathDay=NULL, confirmedCauseOfDeath='Unknown', SireID=NULL, damID=NULL, namePrefix=NULL, nameSuffix=NULL, publication1=' ', publication2=' ', publication3=' ''

 

Now, this isn't my code, I'm helping someone out because the person that wrote this is MIA.

 

Any help is much appreciated.

Thanks in advance

Link to comment
https://forums.phpfreaks.com/topic/108264-need-help-with-a-query/
Share on other sites

Then nothing will show, I only need it to show

Michelle Kramer on 2008-06-01 11:20:22 made change
'Added Owners for 39804'

 

Not all of this

Updated with RegisteredName='Michelle\'s Test Dog', Alias=NULL, CallName=NULL, AKC=NULL, AKCStudBookYear=NULL, AKCStudBookMonth=NULL, CKC=NULL, CKCStudBookYear=NULL, CKCStudBookMonth=NULL, OtherRegistration=NULL, OtherRegistrationCountry=5, Sex='M', Genotype=2, Colour=2, Dentition=1, Height=NULL, Length=NULL, AdultWeight=NULL, DNAprofile=NULL, BirthCountry=3, CauseOfDeath=NULL, birthYear=2008, birthMonth=5, birthDay=30, deathYear=NULL, deathMonth=NULL, deathDay=NULL, confirmedCauseOfDeath='Unknown', SireID=NULL, damID=NULL, namePrefix=NULL, nameSuffix=NULL, publication1=' ', publication2=' ', publication3=' ''

Are you seriously asking how to highlight/delete things out of a string? You find the part in your string you do not wish to have displayed, put your mouse there and click on that spot, and start tapping your delete button.  Or you could get really fancy with some advanced editing skills and drag across to highlight it and then press delete. 

I came here for some help, not to be talked down too.

I'm well aware of how to delete things, thanks for the lesson though, might come in handy later on.

 

Now, I don't what part of the statement that is and why it is showing, that is why I posted the code, to see if maybe somebody here could help out.

 

So you think you might be able to help out, or are smart-alec reponses the only thing in your repertoire??

 

What I don't understand is why does it show this, I don't want that to show, how do I get rid of this

Alias=NULL, CallName=NULL, AKC=NULL, AKCStudBookYear=NULL, AKCStudBookMonth=NULL, CKC=NULL,

 

 

I just need it to show this format that I need to show

Michelle Kramer on 2008-06-01 11:20:22 made change

'Added Owners for 39804'

 

That is what I'm asking

That shouldn't be showing at all, from the code you posted.  Check your loop that calls that function to see if you have some sort of erroneous variable concatted onto where you return the displayed response.  Failing that, look at your performSQLMultiRow function to see if something isn't being erroneously added on there. 

 

It looks like something you (or someone) may have used to echo stuff out for debugging, or else a query building string, that's somehow being tacked onto the end of your output.  But it's not in the code you provided.

This is the moreinfo file

 

include_once "dogTableAccess.php";
$res = editHistroy($_GET['DOGID']);
    if ($res == "")
    {
        echo "<div align=center>This dog has no History recorded</div>";
    }
    else
    {
        echo $res;
    }

 

This is the dogTableAccess file

function editHistroy($DOGID)
{
    $response ="";
    $count = performSQLMultiRow("select firstname, lastname, logentry, changeDate from editHistory left join useraccounts on editHistory.uid = useraccounts.uid  where keyValue = $DOGID AND tableName='DOG'",$result);

    /* Old query

    "select firstname, lastname, logentry, changeDate from editHistory,useraccounts where keyValue = $DOGID AND tableName='DOG' AND editHistory.uid = useraccounts.uid"

    */

    for($i =0;$i <  $count ; $i++)
    {
        $editHistory = mysql_fetch_array($result);
        if ($editHistory['firstname'] == NULL) {
              $response .= "Unknown";
	}
        else {
            $response .= $editHistory['firstname'];
	}

        if ($editHistory['lastname'] != "NULL") {
              $response .= " " . $editHistory['lastname'];
	}
        $response .= " on " . $editHistory['changeDate'] ." made change <br><span class=fontsize1emnormalPROFILEIndented>'" . $editHistory['logentry'] .  "'</span><br><br>";
    }
    return $response;
}

 

This is the vars.php file associated with both files

function logActivity($Activity, $tableName, $keyValue) {
// Make sure $tableName is all capps.

$tableName=strtoupper($tableName);


// Store the datetime value, the date needs to be in this format.
// 'YYYY-MM-DD HH:MM:SS
    if ( isset($_SESSION['UID'])) {
        $UID = $_SESSION['UID'];
    }
    else
    {
       $UID = 0; // 0 is a special UID indicating an unloged in user.
       // Often used when logging the change for a password.

    }
    performSQLNoResult("insert into editHistory (uid, logentry,changeDate, tableName, keyValue) values ($UID,'$Activity','".date("Y-m-d G:i:s") ."', '$tableName', '$keyValue')");
}

 

I cannot find anywhere that this is, on any of these files.

Like I said, this isn't my code

 

This is the only place I could find the function

 

function performSQLMultiRow($SQL, &$result_set)
{
global $linkID, $database;
mysql_select_db("$database", $linkID);
$result = mysql_query($SQL);

if (!$result) {
	echo("<P>ERROR " . mysql_error() ."</P> <p> on SQL: $SQL</p>");
	exit();
}

$result_count = mysql_num_rows($result);
$result_set = $result;

return $result_count ;
}

well..that COULD be it.  That condition does echo out your query string, but I'm looking back at your original output and I'm not really seeing that "SQL : <query string>" or even the error...so...I think I have to take that back and say that I don't think that's it.

Now, I am noticing here:

for($i =0;$i <  $count ; $i++)
    {
        $editHistory = mysql_fetch_array($result);
        if ($editHistory['firstname'] == NULL) {
              $response .= "Unknown";
	}
        else {
            $response .= $editHistory['firstname'];
	}

        if ($editHistory['lastname'] != "NULL") {
              $response .= " " . $editHistory['lastname'];
	}
        $response .= " on " . $editHistory['changeDate'] ." made change <br><span class=fontsize1emnormalPROFILEIndented>'" . $editHistory['logentry'] .  "'</span><br><br>";
    }
    return $response;
}

 

$count comes from

 

$count = performSQLMultiRow("select firstname, lastname, logentry, changeDate from editHistory left join useraccounts on editHistory.uid = useraccounts.uid  where keyValue = $DOGID AND tableName='DOG'",$result);

Making it a result source, which isn't an integer to be counted to.  I think you may need to change your code to:

 


     while($editHistory = mysql_fetch_array($result)) {
        if ($editHistory['firstname'] == NULL) {
              $response .= "Unknown";
	}
        else {
            $response .= $editHistory['firstname'];
	}

        if ($editHistory['lastname'] != "NULL") {
              $response .= " " . $editHistory['lastname'];
	}
        $response .= " on " . $editHistory['changeDate'] ." made change <br><span class=fontsize1emnormalPROFILEIndented>'" . $editHistory['logentry'] .  "'</span><br><br>";

    return $response;
}

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.