Jump to content

Problem with notifications sent out when data added


speckytwat

Recommended Posts

Actually what happens when I change the POST to just $senderid = $_POST['_Sender']; is that although I still get a message saying it was added successfully, when i go into the database table nothing has been added- so removing the intval stops it working.

 

So it works as this (or at least, it adds values to the table - only putting Sender in as 0)

$senderid = intval($_POST['_Sender']);

But not when I change it to this:

$senderid = $_POST['_Sender'];
Link to comment
Share on other sites

Yes, I'm getting the success message when the intval is in the code for POST Sender, and I can confirm that the records are added into the db, except that Sender is inputted as zero instead of the username. If I take the intval out of the POST Sender it doesn't work at all

 

I think that is your problem. You are apparently passing the sender username with the post data and trying to populate that as the foreign key for the sender in the messages table. You should be passing the sender ID. My guess is that the 'Sender' field in the table is an integer field. The intval() function is converting the username string to a 0 and allows the query to work. When you remove the intval() conversion, the query is probably failing because you are trying to insert a string into an integer field.

Link to comment
Share on other sites

I double checked, the Sender field in the db is VARCHAR(50)... thanks for the idea though.

 

So not sure where to go with this now - it works with the intval, but only as far as inputting the records (Sender is still going in as 0). When I remove it so it's just inputting a string, it doesn't work at all, regardless of whether or not $sender is inside single quotes or not...

Link to comment
Share on other sites

Sorry, I'm not sure I understand- there are so many things going on in the thread so I'm not sure which part you're eferring to. Should I have the intval included or not included? If so, what do i need to do in order to have it insert the username rather than an integer (an integer isn't any use to me especially if it's just zero) Or, if I shouldn't include it, then what do I need to do in order to get the INSERT working again? I'm just not clear on that?

 

I did try putting $senderid in single quotes in the INSERT statement but that resulted in no records being inserted, i.e just the same.

 

I don't seem to be any further forward, I just need the sender username inrerted rather than an integer, and for the email notifications to be sent out. Could you let me know what more I need to do to get this set up?

 

It looks like your post came right after mine, so I think you were responding to Barand. Read my last post. It appears you may be trying to insert the 'username' (string) into a field intended for the user ID (integer). You need to use the senders user id, not username.

Link to comment
Share on other sites

Have just copied it up to the server again and (from testing so far) it appears to now be working - email notifications are going out (and only to sender and recipients) and entered into db correctly. Thanks to everyone for the help and persistence with this. Fingers crossed it will stay working now.

Link to comment
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.