Jump to content

help with PM system


ajaxsoundscool

Recommended Posts

Hi guys, im looking for someone to help me with a PM system for my site at www.just-vent.com

 

Its very basic and the graphics are awful, but im trying to get the bare bones of the site before i style it. 

 

So far i have been following tutorials on creating the site and im stuck with the PM system. 

 

I can send and receive messages as ''parent'' messages and it displayes in mysqli table for the pm message system

 

however, on my inbox forms, there are 3 options for each message.. mark as read, delete and reply... 

 

none of them work, you can enter txt and press all the buttons, the buttons animate.rollover, but nothing happens...

 

If anyone would be willing to help it would be gratefully received. 

 

Regards

 

Guy

Link to comment
Share on other sites

Hey,thanks for the reply :)

 

No i didnt write the code, im following a bunch of tutorials, i have added some of my own basic coding however.  I have set up the tables as the tutorial states, then implemented the code, all the file names are correct and in the propper locations in the root ad sub folders. I think it could be that (A) the pm_system.php file has something that isnt communicating with the enum values of the pm table, or (B) the table somehow isnt allowing the connection for the enum values due to something i could have overlooked. I would be willing to upload the system script and a screenshot of my tables if anyone would care to take a look?

 

Regards

 

Guy

Link to comment
Share on other sites

the problem could be anywhere in the form or the form processing code. what have you done to find out what is actually happening in your code when you click on each of the buttons?

 

does the browser go to the target page of the buttons or does it stay on the form page? is the right data being submitted to the target page? is the code seeing the right values in the right places and running the logic for those buttons? are the database queries being formed correctly and being run? do the queries produce any errors?

 

you have 100s of lines of code for these three buttons with 1000s of characters in them. a typo or the wrong variable name or a wrong value anywhere in the code could prevent the buttons from working. you need to debug what your code is actually doing to find out where the problem is at in it.

Link to comment
Share on other sites

Hi guys, somehow, re-uploading the files to the server fixed the issue :/... however, there is a problem with my pm messages... when in chat with someone, you have to refresh the page before you actually get the message. Is there any way of telling the chat box to auto refresh one a new message has been replied to you?

 

I also have another issue, my signup page returns this error... the code that the error is talking about is a code that tells a gif to flash when a new private message is recieved... So, im guessing its something that is to do with the logged in users bit...

 

Warning: mysqli_query() expects parameter 1 to be mysqli, null given in /home/guyrich/public_html/template_pageTop.php on line 9

Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, null given in /home/guyrich/public_html/template_pageTop.php on line 10

 

Here is the code for the template_pageTop.php... 

 

 

 

<?php
//check for new pm's
$pm_n = '<img src="../images/pmStill.gif" width="17" height="12" alt="Pm" title="This pm is for logged in members">';
$sql = "SELECT id FROM pm WHERE
(receiver='$log_username' AND parent='x' AND rdelete='0' AND rread='0')
OR
(sender='$log_username' AND sdelete='0' AND parent='x' AND hasreplies='1' AND sread='0')
LIMIT 1";
$query = mysqli_query($db_connex, $sql); //
$numrows = mysqli_num_rows($query); //   These are the lines in question... 9 and 10
if ($numrows > 0) {
$pm_n = '<a href="../pm_inbox.php?u='.$log_username.'" title="Private Message Notifier"><img src="../images/pmFlash.gif" width="17" height="12" alt="Pm"></a>';
} else {
$pm_n = '<a href="../pm_inbox.php?u='.$log_username.'" title="Private Message Notifier"><img src="../images/pmStill.gif" width="17" height="12" alt="Pm"></a>'; 
}
 
Cheers, Guy
Link to comment
Share on other sites

your first error is because $db_connex doesn't exist. based on the line numbers, that's probably all your code and you aren't making a database connection at all, let alone a connection in $db_connex.

 

your second error is because of the first error.

Edited by mac_gyver
Link to comment
Share on other sites

Hey, thanks for the replies. db_connex does exist, my update status section works fine with the db_connex, and the private message function connects fine too, this error pops up in a section of code that tells the .gif on page top to animate when a new message is received  this works fine... I only get the error on my signup page, so when a user isn't logged in i think the code is failing to say that the icon should be inaccessible for not logged in users. 
My db_connex.php is located in a php includes folder..

 

 

<?php
$db_connex = mysqli_connect("localhost", "username", "*****************.", "guyrich_social");
//Evaluate the connection
if (mysqli_connect_errno()) {
echo mysqli_connect_error();
exit();
}
?>



And here is the code snippet from template_pageTop.php
 
<?php
//check for new pm's
$pm_n = '<img src="../images/pmStill.gif" width="17" height="12" alt="Pm" title="This pm is for logged in members">';
$sql = "SELECT id FROM pm WHERE
(receiver='$log_username' AND parent='x' AND rdelete='0' AND rread='0')
OR
(sender='$log_username' AND sdelete='0' AND parent='x' AND hasreplies='1' AND sread='0')
LIMIT 1";
$query = mysqli_query($db_connex, $sql);
$numrows = mysqli_num_rows($query);
if ($numrows > 0) {
$pm_n = '<a href="../pm_inbox.php?u='.$log_username.'" title="Private Message Notifier"><img src="../images/pmFlash.gif" width="17" height="12" alt="Pm"></a>';
} else {
$pm_n = '<a href="../pm_inbox.php?u='.$log_username.'" title="Private Message Notifier"><img src="../images/pmStill.gif" width="17" height="12" alt="Pm"></a>'; 
}
// It is important for any file that includes this file, to have
// check_login_status.php included at its very top.
$envelope = '<img src="images/note_dead.jpg" width="22" height="12" alt="Notes" title="This envelope is for logged in members">';
$loginLink = '<a href="login.php">Log In</a>   |   <a href="signup.php">Sign Up</a>';
if($user_ok == true) {
$sql = "SELECT notescheck FROM users WHERE username='$log_username' LIMIT 1";
$query = mysqli_query($db_connex, $sql);
$row = mysqli_fetch_row($query);
$notescheck = $row[0];
$sql = "SELECT id FROM notifications WHERE username='$log_username' AND date_time > '$notescheck' LIMIT 1";
$query = mysqli_query($db_connex, $sql);
$numrows = mysqli_num_rows($query);
    if ($numrows == 0) {
$envelope = '<a href="notifications.php" title="Your notifications and friend requests"><img src="images/note_still.jpg" width="22" height="12" alt="Notes"></a>';
    } else {
$envelope = '<a href="notifications.php" title="You have new notifications"><img src="images/note_flash.gif" width="22" height="12" alt="Notes"></a>';
}
    $loginLink = '<a href="user.php?u='.$log_username.'">'.$log_username.'</a>   |   <a href="logout.php">Log Out</a>';
}
?>
 
 

 
Edited by ajaxsoundscool
Link to comment
Share on other sites

Do you think it could be that its checking for new PM's for logged in users and wont connect to the database because their not logged in?

 

how would anyone here know if your code is doing that or if that is even relevant to the problem? you have all the code, you should be able to answer that question yourself.

 

 

Warning: mysqli_query() expects parameter 1 to be mysqli, null given in /home/guyrich/public_html/template_pageTop.php on line 9

 

this is your error message. did you read it and try to solve this yourself? you are calling the mysqli_query() function. it expects parameter 1 to be an instance of a mysqli connection. you are supply a null non-existent value.

 

you have either not made a database connection, have closed the database connection, or the program scope where the template code is running at is not the same program scope where the connection exists.

Edited by mac_gyver
Link to comment
Share on other sites

Hi guys, it was a silly error, I forgot to include a check_login_status.php file at the top of the page. Did that, everything works swimmingly, well...in terms of messages flying backwards and forwards. 

 

Now i just have the issue or having to refresh the page to view messages all the time,,, its not instant, so the next task is to set up an instant message system. This is something i haven't ventured into yet so if anyone knows any great resources, please let me know :)

 

Thank you all for your help!

 

Guy

Link to comment
Share on other sites

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.