I have adjusted a lot of the code that I posted earlier but nothing seems to work, I put in the code to show all errors and I am not getting any errors returened after I fixed the single minor misstype of adding an extra "(" into the code, i am now faceing a completely blank div with no ideas left as to where to even start looking for the problem

<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);

include 'conect.php';

$deets = $_POST['deets'];
$deets = preg_replace('#[^0-9/]#i', '', $deets);

$events = '';
$query = mysql_query('SELECT description FROM events WHERE date = "'. $deets .'"');
$num_rows = mysql_num_rows($query);

if($num_rows > 0)
{
    $events .= '<div id = "eventsControl"><button onClick = "overlay()">Close</button><br /><br /><b>' . $deets . '</b><br /><br /></div>';

    while($row = mysql_fetch_array($query))
    {
        $desc = $row['description'];
        $events .= '<div id = "eventsBody">' . $desc . '<br /><hr><br /></div>';
    }
}
echo $events;
?>

this is the events.php, this is not comunicating properly with the show_details function in my show_calendar.php

function show_details(theId)
{
    var deets = (theId.id);

    e1 = document.getElementById("overlay");
    e1.style.display = (e1.style.display == "block") ? "none" : "block";
    e1 = document.getElementById("events");
    e1.style.display = (e1.style.display == "block") ? "none" : "block";

    var hr = new XMLHttpRequest();
    var url = "events.php";
    var vars = "deets=" + deets;

    hr.open("POST", url, true);
    hr.setRequestHeader("content-type", "application/x-www-form-urlencoded");

    hr.onreadystatechange = function()
    {
        if(hr.readyState == 4 && hr.status == 200)
        {
            var return_data = hr.responseText;
            document.getElementById("events").innerHTML = return_data;
        }
    }
    hr.send(vars);
    document.getElementById("events").innerHTML = "Processing...";
}

can anyone please spot what i am missing? these two are suposed to be comunicating and for some reason they arent. i will post also the code that calls the show_details()

for($i = 1; $i <= $day_count; $i++)
{
    $date = $showMonth . '/' . $i . '/' . $showYear;
    $query = mysql_query('SELECT id FROM events WHERE date = "'.$date.'"');
    $num_rows = mysql_num_rows($query);

    if($num_rows > 0)
    {
        $event = "<input name = '$date' type = 'submit' value = 'Details' id = '$date' onClick = 'javascript:show_details(this);'>";
    }
    echo '<div class = "cal_day">';
    echo '<div class = "day_heading">' . $i . '</div>';

    if($num_rows != 0)
    {
        echo "<div class = 'openings'><br />" . $event . "</div>";
    }
    echo '</div>';
}

Recommended Answers

All 10 Replies

Member Avatar for LastMitch

@GraficRegret

ut in the code to show all errors and I am not getting any errors returened after I fixed the single minor misstype of adding an extra "(" into the code, i am now faceing a completely blank div with no ideas left as to where to even start looking for the problem

There should be a an error. Try the following:

Try to put or die(mysql_error()); on here:

$query = mysql_query('SELECT description FROM events WHERE date = "'. $deets .'"');

From this:

$query = mysql_query('SELECT description FROM events WHERE date = "'. $deets .'"');

To this:

$query = mysql_query('SELECT description FROM events WHERE date = "'. $deets .'"') or die(mysql_error());

Same for this line add or die(mysql_error()); on here too:

$query = mysql_query('SELECT id FROM events WHERE date = "'.$date.'"');

From this:

$query = mysql_query('SELECT id FROM events WHERE date = "'.$date.'"');

To this:

$query = mysql_query('SELECT id FROM events WHERE date = "'.$date.'"') or die(mysql_error());

I will try that thanks, the only part of the for statment that I am questioning however is this

$event = "<input name = '$date' type = 'submit' value = 'Details' id = '$date' onClick = 'javascript:show_details(this);'>";

namely, the "onClick" call, the rest of the for statment goes off without a hitch.

Member Avatar for LastMitch

namely, the "onClick" call, the rest of the for statment goes off without a hitch.

Are you trying try ajax the data from the db?

I'm not familiar with javascript.

But this looks wrong to me:

onClick = 'javascript:show_details(this);

It should look something like this:

onClick="showDetails('<?php echo $this;?>');

Also try double qoutes instead of single qoutes

The function it is calling is a javascript function which I am familiar with, the call is acurate, its the other end that I am kind of questioning, following the code trail you will see that your php code would not work with the way the code is set up.

Member Avatar for LastMitch

I am kind of questioning, following the code trail you will see that your php code would not work with the way the code is set up.

$event = "<input name = '$date' type = 'submit' value = 'Details' id = '$date' onClick = 'javascript:show_details(this);'>";

What is (this)?

Right now, is there any errors now? I mean when you put or die(mysql_error()); on those query did any errors appear?

If there's no error, then your db and query is connected then the issue would be in javascript.

I hope that answer your question regarding why there's no errors in the php part.

in javascript when you refer to function_name(this) it refers to the object that said function is attached to, or the object that the mouse is clicking on. I will be able to let you know if there are any errors after a bit i just got into the office.

still no errors being reported

Hi,

Did you try changing this

$query = mysql_query('SELECT description FROM events WHERE date = "'. $deets .'"');

to this?

$query = mysql_query('SELECT description, date FROM events WHERE date = "'. $deets .'"');
Member Avatar for LastMitch

still no errors being reported

If there's no error from the connection. Try reorganized this statement:

$event = "<input name = '$date' type = 'submit' value = 'Details' id = '$date' onClick = 'javascript:show_details(this);'>";

From this:

$event = "<input name = '$date' type = 'submit' value = 'Details' id = '$date' onClick = 'javascript:show_details(this);'>";

Try this:

$event = "<input type ='submit' name='date' value='<?php echo $_POST['date']; ?>' onClick = 'javascript:show_details(this);'>";

Let me know how this goes.

I will give that a try, im going to close this threead though as I am being asked to move on from this problem to another project and come back to this later, Thanks for all your advice.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.