KansukeKojima
Mar 28 2008, 07:01 PM
Alright... so this is really my first time using databases at all. Anyways, I need some help. http://2kart.trap17.com/shoutbox.phpI used a tutorial from spoono.com (http://www.spoono.com/php/tutorials/tutorial.php?id=19) to create this... everything seems to work, except that it won't show what is posted in the shoutbox..... my code is below.... and since I hardly know anything about databases, I'm sure you'll find an error quickly. Thanks! CODE <?php //host name password mysql_connect("localhost","name","password");
//select database mysql_select_db("shoutboxdatabase");
if($submit) { //date function $time=date ("h:ia d/j/y");
//insert into shoutbox table $result=MYSQL_QUERY("INSERT INTO shoutbox (id,name,message,time)". "VALUES ('NULL','$name', '$message','$time')"); }
//last five messages $result = mysql_query("select * from shoutbox order by id desc limit 5");
//while loop while($r=mysql_fetch_array($result)) { //variables from table $time=$r["time"]; $id=$r["id"]; $message=$r["message"]; $name=$r["name"]; ?>
<?php $time ?><br /> <?php echo $name ?><br /> <?php echo $message ?><br /> <?php } ?> <form action="<?php echo $php_self ?>" method="post"> <INPUT TYPE='TEXT' value='Name' NAME='name' SIZE=30 maxlength='100'><br /> <INPUT TYPE='TEXT' value='Message' NAME='message' size=30 maxlength='100'> <input type="submit" name="submit" value="Submit"> </form>
Reply
shadowx
Mar 28 2008, 07:34 PM
The first thing i notice is this line: QUOTE mysql_select_db("shoutboxdatabase"); Is this how it is in the code or have you changed the DB name to hide it? The reason i ask is that with T17 you need to prefix the DB name with your hosting username EG: If my cpanel login name was "shadowx" (which it isnt by the way...) My DB name would be "shadowx_shoutboxdatabase" I dont have time to look through the code so if this isnt the problem someone else will have to help!
Reply
KansukeKojima
Mar 28 2008, 07:38 PM
yeah... just never mind all the db connect stuff... I changed it to hide the info....
Reply
sonesay
Mar 28 2008, 09:53 PM
Either check through cpanel if entries are being inserted into the database using myphpadmin or what ever its called. Then if entries are being inserted there check your actually receiving results from the query by using CODE $found = mysql_num_rows($result); echo $found; if your getting the correct return entries then we can assume its correct and the error is on the loop where you try and output the results. How you have done it I never do CODE while($r=mysql_fetch_array($result)) { //variables from table $time=$r["time"]; $id=$r["id"]; $message=$r["message"]; $name=$r["name"]; ?>
<?php $time ?><br /> <?php echo $name ?><br /> <?php echo $message ?><br /> <?php } ?> CODE while($r=mysql_fetch_array($result)) { //variables from table $time=$r["time"]; $id=$r["id"]; $message=$r["message"]; $name=$r["name"];
echo $time."<br />"; echo $name."<br />"; echo $message."<br />"; }
?> I would just keep the while loop in side the same php tags. I dont know what the effect of it doing your way does but obviously it did not pick up the error when you tried to just do "$time" with no echo  . just try it this way and see if it works.
Reply
jlhaslip
Mar 28 2008, 11:06 PM
Can you get results from the Database using this Query in the phpMyAdmin using the SQL function? CODE select * from shoutbox order by id desc limit 5" Also, add this after the query in your script to see what the script is getting for results: CODE print_r( $result ); Of course, set error reporting at the top of the script to see if the script is tossing an error: CODE ini_set("display_errors", 1); error_reporting(E_ALL);
Reply
KansukeKojima
Mar 28 2008, 11:18 PM
I think that this may be it. QUOTE Notice: Undefined variable: submit in /home/kansuke/public_html/shoutbox.php on line 11 Resource id #3 ... what is the undefined variable in the code? and it rejects the query you said to use...
Reply
sonesay
Mar 28 2008, 11:23 PM
you didnt say if that was your entire code you posted. Looking at it now $submit is not defined as when its submitted your checking if($submit refer to it as $_POST['submit'];
Reply
truefusion
Mar 29 2008, 03:13 AM
A couple of suggestions: Replace: CODE while($r=mysql_fetch_array($result)) { //variables from table $time=$r["time"]; $id=$r["id"]; $message=$r["message"]; $name=$r["name"]; ?>
<?php $time ?><br /> <?php echo $name ?><br /> <?php echo $message ?><br /> <?php } ?> With: CODE while($r=mysql_fetch_assoc($result)){ //variables from table echo $r["time"]."<br/>\n".$r["id"]."<br/>\n".$r["name"].":<br/>\n".$r["message"]."<br/>\n"; } ?> to save some space, and to receive an associative array from the result. And since the form is going to be submitted to the same page it's in, you can have simply this: HTML <form action="" method="post">
Reply
electriic ink
Mar 30 2008, 04:18 PM
Also, your output code reads this: CODE <br /> <b>Notice</b>: Undefined variable: submit in <b>/home/kansuke/public_html/shoutbox.php</b> on line <b>11</b><br /> Resource id #3<form action="<br /> <b>Notice</b>: Undefined variable: php_self in <b>/home/kansuke/public_html/shoutbox.php</b> on line <b>37</b><br /> " method="post"> <INPUT TYPE='TEXT' value='name' NAME='name' SIZE=30 maxlength='100' /><br /> <INPUT TYPE='TEXT' value='message' NAME='message' SIZE=30 maxlength='100' /><br /> <input type="submit" name="submit" value="submit"> </form> The error is on the following line in the source code: CODE <form action="<?php echo $php_self ?>" method="post"> Which should read: CODE <form action="<?php echo $SERVER['PHP_SELF']; ?>" method="post">
Reply
KansukeKojima
Mar 31 2008, 06:30 PM
QUOTE(sonesay @ Mar 28 2008, 05:23 PM)  you didnt say if that was your entire code you posted. Looking at it now $submit is not defined as when its submitted your checking if($submit
refer to it as $_POST['submit']; I think that would maybe solve it... but, where am I supposed to place it? I'm not quite clear on where you want me to place $_POST['submit'].
Reply
Latest Entries
KansukeKojima
Apr 1 2008, 08:21 PM
Err... yeah wait... I'll try out what you said in your previous post... *EDIT* Ok, I did what you suggested in the previous post. Works like a charm! Thank you so much!! feel free to test it out http://2kart.trap17.com (click the 'Open Shoutbox Window' link) EDIT 2 bbcode is now included.
Reply
sonesay
Apr 1 2008, 08:09 PM
if you really need to do it on the same page and not like how I said previous post with submitting to another page then redirecting back to the original. that way save post variables are lost then.. You can probably do it with some javascript. Set a flag for when the submit button is acutally pressed. That way you can distinguish between page reloads and real submissions. I wont give you exact code but that is the idea. Have a onclick function on your button to set flag that it is a real submit then check on your if statement code. If you really need the exact logic and code reply lol.
Reply
KansukeKojima
Apr 1 2008, 06:35 PM
Thanks jlhaslip, I tried what you posted unfortuneately, it does not work. But, I've found something that does, and unless someone can come up with a better method... <iframes>! Fortuneately, it keeps the shoutbox from re-posting... so I'll probably be using them... unfortuneately xD... If someone has a better idea...I'll use it.
Reply
jlhaslip
Apr 1 2008, 05:05 AM
Does this work any better? I have adjusted it a little so that it checks to see if the Form is 'set' before assigning the variables used. CODE <? ini_set("display_errors", 1); error_reporting(E_ALL); //the host, name, and password for your mysql mysql_connect("localhost","not tellin you!","not tellin");
//select the database mysql_select_db("not tellin"); if(isset($_POST['submit'])) { $submit = $_POST['submit']; $name = $_POST['name']; $message = $_POST['message']; //use the PHP date function for the time $time=date("h:ia d/j/y"); // inserting it into the shoutbox table which we made in the mysql statements before $result=MYSQL_QUERY("INSERT INTO shoutbox (id,name,message,time)". "VALUES ('NULL','$name', '$message','$time')"); } ?> <? //returning the last 5 messages $result = mysql_query("select * from shoutbox order by id desc limit 5");
//the while loop while($r=mysql_fetch_assoc($result)){ //variables from table echo $r["time"]."<br/>\n".$r["id"]."<br/>\n".$r["name"].":<br/>\n".$r["message"]."<br/>\n"; } ?> <form action="" method="post"> <INPUT TYPE='TEXT' value='name' NAME='name' SIZE=30 maxlength='100' /><br /> <INPUT TYPE='TEXT' value='message' NAME='message' SIZE=30 maxlength='100' /><br /> <input type="submit" name="submit" value="submit"> </form>
Reply
sonesay
Apr 1 2008, 04:48 AM
The reason why its keeps reposting is because the post variable are saved since its posted to the same page. When you reload you reload the post lol. The only other way to do it so you can reload that page without double posting is to have it submit to a page thats designed specifically for inserting in to the database. Then redirect it back to the original page where you display form and last previous five message. I'm pretty sure that will work so you need an extra php page. I dont think its possible to destroy post variables after a post. I could be wrong but I dont think we have acess to anything like that.. doubt it lol.
Reply
Similar Topics
Keywords : shout, box
- Safari And Trap17 Shout Box
Shout box not displaying in safari (2)
More Color Choice In Shout Box Text
Purple please. (8) Hey, how about adding more color options for the text in the shout box. I would like to see
purple added. ....
Shout Box Banned....
(1) I got banned from the shout box because I posted an image (I think).... But I read the rules and
it's says I can post small images and I posted a small image... I'm reallllyyyy sorry if
it was my mistake... /cool.gif" style="vertical-align:middle" emoid="B)" border="0" alt="cool.gif"
/>....
Not Happy At All! Chatz Last Shout!
Things that make me sick about trap (9) Right,today I had about 68 credits,when i returned later today i found that my credits have been
reduced to 64 and i got a warn.NOW! I know for a fact that all that i posted was not copied you
can search the intire net (i even help you) and you will not find that i posted any copied matrial,i
also didn't swear or abuse anther user.SO I WOULD LIKE TO KNOW WHY WAS I WARNED? /mad.gif"
style="vertical-align:middle" emoid=":angry:" border="0" alt="mad.gif" /> Or is this the way of
"trap17"?....
Wappyshout V1.60c
my popular wap shout box script :-) (3) ---------------------------- wappySHOUT v1.60c ----------------------------
---------------------------- ABOUT: ---------------------------- wappySHOUT is a simple shoutBOX
system for WAP sites that works as a stand alone script so you can use it on any page without having
to play about with your existing code, so users can leave short comments on your site. Almost like a
basic guestbook. It also has 130 smileys built in, history page, smileys page, user info etc..
---------------------------- INSTALLATION: ---------------------------- Simply upload all files and
the smi....
New Site - Shout It Out!
www.shout-it-out.net (32) Well I have a new site online, it's nothing fancy but maybe some poeple like the idea: basically
it is a modified guestbook, anybody can post, without being registered, and poeple can comment on
the posts, but it is definetly not a forum, whoever feels like randomly shouting something can.
Have a look at it and tell me what you think: http://blacklaser.trap17.com/shout/ I'll
probably get a domain for it pretty soon too, let me know what you think! Thanks in advance for
any feedback. /cool.gif" style="vertical-align:middle" emoid="B)" border="0" alt="co....
Make Smilie Page Load Faster In Shout Box
(0) Well for me when I click on the smilies button, it takes it about 30 seconds to even open the window
with the smilies. Don't know if you can make it faster, but it would help me.....
Shout_box_v8.5.2 Installation Problem
(2) i downloaded this file for my php site...and it didnt work for me because the files i installed in
there couldnt link together correctly...there are 3 folders a sql, Public_html and Conversion tool
in the shoutbox file i just downloaded...i installed all the folders into my server...then i tried
adding the block and activating my shoutbox block and shout module....but they didnt quite work
because they had to communicate with the stuff in the sql folder....this was a problem becuase my
phpnuke stuff is all in a folder called "nuke" which is in my Public_html folder....s....
Report Button On Shout Box
(4) I think that we could do with a report button..because recently there have been many weirdoes around
here that post things that they shouldn't be posting...so maybe someone can make a script and we
can have a report page just for the shout box...designed just for the shoutbox.... for example i
know it cant be like a topic where there is automaticly a report button there, but maybe we can make
a page on the forums that is exactly like the normal report page and it does the same thing (sends
it to all mods and admins) just a thought....
Your Shout Box
please read (1) your shout box has a time delay on in and i think it should not be so long!....
Shout Box In My Website
How to put shout box in my own website?? (7) I just created my own website, its www.comaid.trap17.com my purpose here is to provide helpful tips
to all my friends and other new in IT. I want to put shoutbox on it but honestly don't how to
create eh... my friend told me that I can download it from the net, but found nothing... Is there
anybody there can help me how to create or put shoutbox in my website... I am not expert in internet
programming eh... that is why I posted my topic here to ask for assistant to those generous users
and members of trap17... thanks in advance... /rolleyes.gif' border='0....
Free Shout Boxes
(0) I just found this cool site and decided to share it with ou guys. Simple little program puts shout
box on your site, no programming needed ( :cry: )
www.shoutboxes.com ......enjoy........
Shout Box
(3) hey I just wanted to know does anyone have a reliable script for a shout box, I've been looking but
couldn't find one... if you do, then can I please have it... Thank you /biggrin.gif' border='0'
style='vertical-align:middle' alt='biggrin.gif' /> ....
Shout Box General Error !?!
(5) CODE Could not get shoutbox information DEBUG MODE SQL Error : 1146 Table
'freenuke_phpbb.SHOUTBOX_TABLE' doesn't exist SELECT s.*, u.user_allowsmile, u.username FROM
SHOUTBOX_TABLE s, phpbb_users u WHERE s.shout_user_id=u.user_id ORDER BY s.shout_session_time DESC
LIMIT 0, 20 Line : 98 File : /home/freenuke/public_html/forums/shoutbox_view.php
Anyone who face this problem too? Or it is just me..?....
Shoutbox
Shout Box (3) /ph34r.gif' border='0' style='vertical-align:middle' alt='ph34r.gif' /> I personaley want the
shout box to be instant. /ph34r.gif' border='0' style='vertical-align:middle' alt='ph34r.gif' /> ....
The Board Alert At The Top Of The Page
(above the shout box) (2) the alert at above the shoutbox has bothered me for a while. please fix the mistakes. I feel
notices like this should be done professionally. It doesn't look good on the board. "Spamming
will not be tolerated and WILL be dealt WITH severely. Your posts must mean something and
CLARIFY your point..." these are the ones that bother me most.. everytime I load a page, the thing
stares me in the face. that's what loads first and i have nothing to do but read it until the
rest of the page finishes loading.....
Shout Box
how do u?? (4) how do u put a shout box in a site. i need a pre made one bc it would take foreva for me to make it
lol thx jon....
[Code] - Shout Box
Invision Power Board v1.3.0g (4) Code for Invision Power Board v1.3.0g Just please in headers/footers in admin CODE
<script> // IF Shoutbox v1.0 - Leave Copyright Intact Wherever Used // Created For Invision
Free // Author: Zero Tolerance © Game Zone | Evolution 2004 [http://gzevolution.net]
// Special Thanks To ffmasters.us For Hosting PHP Data + mySQL Allowance Site =
"http://"+document.domain+"/" Site =
location.href.substring(Site.length) if(Site.match('/')){ Site =
Site.split('/')[0] } thissit....
Looking for shout, box
|
|
Searching Video's for shout, box
|
advertisement
|
|