•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the MySQL section within the Web Development category of DaniWeb, a massive community of 425,928 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 1,671 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our MySQL advertiser: Programming Forums
Views: 2566 | Replies: 13
![]() |
•
•
Join Date: Mar 2006
Location: Montreal Quebec Canada
Posts: 52
Reputation:
Rep Power: 3
Solved Threads: 0
Hello Pro Programmers!
Can you help me, Please!!!
What I want to do is let my users message each other, I have my form and message page setup I love it! It’s working the messages are going in the right ID’S in the Mysql database, BUT! It is overwriting as soon as the next message is sent.
I want it to save all messages not overwrite any at all and let the user delete the messages as they so wish to delete
Can I do this is it possible? I have it set up so far on mysql MSG with TEXT Do I use blob instead, can you tell me the php code so it does not overwrite in the mysql database and saves all the messages…
Thank-You Pro Programmers, puddin
Can you help me, Please!!!
What I want to do is let my users message each other, I have my form and message page setup I love it! It’s working the messages are going in the right ID’S in the Mysql database, BUT! It is overwriting as soon as the next message is sent.
I want it to save all messages not overwrite any at all and let the user delete the messages as they so wish to delete
Can I do this is it possible? I have it set up so far on mysql MSG with TEXT Do I use blob instead, can you tell me the php code so it does not overwrite in the mysql database and saves all the messages…
Thank-You Pro Programmers, puddin
•
•
Join Date: Mar 2006
Location: Montreal Quebec Canada
Posts: 52
Reputation:
Rep Power: 3
Solved Threads: 0
Thanks so much for your reply,
Now I am trying to use your suggestion , I think you may be right. But with INSERT INTO when I try to add the user id # like in UPDATE I can add the user id -Like this: id='2'");
But with INSERT INTO It does not work! I would appreciate any help again, Thank-you , puddin
Now I am trying to use your suggestion , I think you may be right. But with INSERT INTO when I try to add the user id # like in UPDATE I can add the user id -Like this: id='2'");
But with INSERT INTO It does not work! I would appreciate any help again, Thank-you , puddin
Last edited by puddin : Jul 6th, 2006 at 12:48 pm.
•
•
Join Date: Jul 2006
Posts: 19
Reputation:
Rep Power: 3
Solved Threads: 1
Ok, this should just be a matter of syntax. For your query, use:
See here for more in-depth info (my example is a little short to be really useful):
http://www.w3schools.com/sql/sql_insert.asp
INSERT INTO table_name (id) VALUES ('2')See here for more in-depth info (my example is a little short to be really useful):
http://www.w3schools.com/sql/sql_insert.asp
•
•
•
•
Originally Posted by puddin
Thanks so much for your reply,
Now I am trying to use your suggestion , I think you may be right. But with INSERT INTO when I try to add the user id # like in UPDATE I can add the user id -Like this: id='2'");
But with INSERT INTO It does not work! I would appreciate any help again, Thank-you , puddin
•
•
Join Date: Mar 2006
Location: Montreal Quebec Canada
Posts: 52
Reputation:
Rep Power: 3
Solved Threads: 0
This is what I have , it's not working, it's creating a new id and not going into (id) VALUES ('2')
<?php
include'db.php';
$sql = mysql_query("INSERT INTO myd (id, fm, mg, last_login)VALUES
('$2','$fm','$mg', now())") or die (mysql_error());
if(!$sql){
echo 'There has been an error creating your account. Please contact the webmaster.';
} else {
echo("");
}
?>
Now in mysql table under fm and mg They Represent: who the message is fm=from and the mg=message : I have them set as a blob: Do you think that is correct?
I did that thinking it could hold a lot of messages : You see I want my users to be able to message each other - and when they click on their message button - They can view all their messages sent by other members -
I want to add a delete button beside each message so the user can delete their messages as they desire.
I have my message form setup great ,
You write your message,
It automatically goes to the mysql table correctly
Postes your message in the right users id -
Than it posts your messsage correctly on the users page
who you sent your message to...
Last it automatically includes that the message is from you...
But when a second message is sent it erases your message. I was using UPDATE now I am trying to use INSERT INTO.
I need mysql table to keep all messages. Users are listed by AUTO INCREMENT 1,2,3 and so on...
I want to allow the user on their message page to see all their messages I want to show a delete button beside each message and let the user delete their messages as they wish.
Thanks again so much, this is the last part of my site so any help again is much appreciated, puddin I also would like the user to recieve an email letting them know, they have a message! I think that part shouldn't be difficult.
<?php
include'db.php';
$sql = mysql_query("INSERT INTO myd (id, fm, mg, last_login)VALUES
('$2','$fm','$mg', now())") or die (mysql_error());
if(!$sql){
echo 'There has been an error creating your account. Please contact the webmaster.';
} else {
echo("");
}
?>
Now in mysql table under fm and mg They Represent: who the message is fm=from and the mg=message : I have them set as a blob: Do you think that is correct?
I did that thinking it could hold a lot of messages : You see I want my users to be able to message each other - and when they click on their message button - They can view all their messages sent by other members -
I want to add a delete button beside each message so the user can delete their messages as they desire.
I have my message form setup great ,
You write your message,
It automatically goes to the mysql table correctly
Postes your message in the right users id -
Than it posts your messsage correctly on the users page
who you sent your message to...
Last it automatically includes that the message is from you...
But when a second message is sent it erases your message. I was using UPDATE now I am trying to use INSERT INTO.
I need mysql table to keep all messages. Users are listed by AUTO INCREMENT 1,2,3 and so on...
I want to allow the user on their message page to see all their messages I want to show a delete button beside each message and let the user delete their messages as they wish.
Thanks again so much, this is the last part of my site so any help again is much appreciated, puddin I also would like the user to recieve an email letting them know, they have a message! I think that part shouldn't be difficult.
•
•
Join Date: Jul 2006
Posts: 19
Reputation:
Rep Power: 3
Solved Threads: 1
Is the
One trick I used to use a lot when beginning with PHP/MYSQL (not to imply you're a beginner!) is to assign the query string to a variable and then echo the string to make sure it looks like it's supposed to. Like this:
[php]$query = "SELECT * FROM table_name"; //using your query, of course
echo $query;
$result = mysql_query($query);
if (!result) { echo "error with db query!"; }[/php]
In your case, you will be able to see exactly what query your computer thinks your are trying to perform. If that doesn't point you to the problem, post back your intended query in PHP format and then what is echoes to your browser. That $2 seems awfully strange to me though.
-----
As far as the BLOBs go, it's probably the right choice for the message, but depending on what exactly you're storing for the 'from' field, you could probably use VARCHAR (and then you would specify the max number of characters - like 200 or whatever you choose). For instance, if the from field is a username and you specify a maximum length for username as 30 characters, then you would use VARCHAR(30). The VARCHAR type can hold a max of 255 characters.
---
I've used the PHPMailer class (http://phpmailer.sourceforge.net/) without any problems. There may be something better out there now, haven't looked in a year or so.
$2 in your query supposed to be a PHP variable? It may be a typo, but if not I don't think PHP allows a variable to begin with a number.One trick I used to use a lot when beginning with PHP/MYSQL (not to imply you're a beginner!) is to assign the query string to a variable and then echo the string to make sure it looks like it's supposed to. Like this:
[php]$query = "SELECT * FROM table_name"; //using your query, of course
echo $query;
$result = mysql_query($query);
if (!result) { echo "error with db query!"; }[/php]
In your case, you will be able to see exactly what query your computer thinks your are trying to perform. If that doesn't point you to the problem, post back your intended query in PHP format and then what is echoes to your browser. That $2 seems awfully strange to me though.
-----
As far as the BLOBs go, it's probably the right choice for the message, but depending on what exactly you're storing for the 'from' field, you could probably use VARCHAR (and then you would specify the max number of characters - like 200 or whatever you choose). For instance, if the from field is a username and you specify a maximum length for username as 30 characters, then you would use VARCHAR(30). The VARCHAR type can hold a max of 255 characters.
---
I've used the PHPMailer class (http://phpmailer.sourceforge.net/) without any problems. There may be something better out there now, haven't looked in a year or so.
•
•
Join Date: Mar 2006
Location: Montreal Quebec Canada
Posts: 52
Reputation:
Rep Power: 3
Solved Threads: 0
I am a beginner 100% I love working with programming a lot, everytime I learn something new I get this big smile!
I have it setup that that the message is viewed before posting but what you have showed is excellent!, thanks,
I'm still trying to get the INSERT INTO to work, I'm hoping it will not overwrite the last message, any other suggestions on that?
Thanks again, puddin
I have it setup that that the message is viewed before posting but what you have showed is excellent!, thanks,
I'm still trying to get the INSERT INTO to work, I'm hoping it will not overwrite the last message, any other suggestions on that?
Thanks again, puddin
•
•
Join Date: Mar 2006
Location: Montreal Quebec Canada
Posts: 52
Reputation:
Rep Power: 3
Solved Threads: 0
Sorry about the typo question, no I thought it would work, but it does not nor without it... if I script it like :
INSERT INTO table_name (id) VALUES ('2') It still creates a new ID.
It echos but it creates a new column a new id in my table,
I need it to go into id=2 than it would display on id2's messages page , you see what I mean... and it doesn't work
INSERT INTO table_name (id) VALUES ('2') It still creates a new ID.
It echos but it creates a new column a new id in my table,
I need it to go into id=2 than it would display on id2's messages page , you see what I mean... and it doesn't work
Last edited by puddin : Jul 6th, 2006 at 11:31 pm.
![]() |
•
•
•
•
•
•
•
•
DaniWeb MySQL Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Similar Threads
Other Threads in the MySQL Forum
- Previous Thread: Need authoritative source on safety of resetting ft_min_word_len
- Next Thread: Desperate again


Linear Mode