crzyman Posted September 15, 2006 Share Posted September 15, 2006 Hello. This is driving me nuts. I have a page that loads information from a database into a page using the include statement. So if the varible $name = "Joe" then it will pull all the information from the database for joe. This works great. Now I am trying to make a shout box on the page. This is my code:comment.php[code]<?PHP$myValue = "Joe";?><form action="test.php" method="GET"><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="hidden" name=$myValues <input type="submit" name="submit" value="submit"> </form>[/code]This creates the form that allows a user to enter his/her name and message. It calls test.php, which looks like this:[code]<?mysql_connect("localhost","name","password");mysql_select_db("news");$artist_name = $_GET['$myValues'];if($submit){ $time=date("h:ia d/j/y"); $result=MYSQL_QUERY("INSERT INTO shoutbox (id,artist_name,name,message,time)". "VALUES ('NULL','$artist_name','$name', '$message','$time')");}?>[/code]The information for $myValue doesn't get entered into the database. The rest of it works. Somehow I have to pass the value of $myValue to the script, test.php, from the form which is comment.php. Can this even be done or am I way out of key here? Please advise. Quote Link to comment https://forums.phpfreaks.com/topic/20901-help-with-a-simple-shout-box-solved/ Share on other sites More sharing options...
Ninjakreborn Posted September 15, 2006 Share Posted September 15, 2006 first redo some of the code, put the query itself into a variable like$insert "INSERT INTO tablename ...;";then do the query with a handle $query = mysql_query($insert)ex cetera, then below everything type inecho mysql_error();then return the error message here.If no error messages comes up, check your variables by echoing each of them, find out which ones are getting filled and which ones are empty. Quote Link to comment https://forums.phpfreaks.com/topic/20901-help-with-a-simple-shout-box-solved/#findComment-92596 Share on other sites More sharing options...
craygo Posted September 15, 2006 Share Posted September 15, 2006 Well first you did not close your tags and second you didn't give it a value. Right now you are giving that value a name of Joe.Is that your intention???try this[code]<input type="hidden" name=myValues value="<?=$myValue?>">[/code]also $submit will not work unless you have globals turned on, which they are not by default[code]if(isset($_GET['submit'])){[/code]Here is revised code[code]<?php$myValue = "Joe";?><form action="test.php" method="GET"><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="hidden" name=myValues value="<?=$myValue?>"> <input type="submit" name="submit" value="submit"> </form>[/code][code]<?phpmysql_connect("localhost","name","password");mysql_select_db("news");$artist_name = $_GET['myValues'];if(isset($_GET['submit'])){ $time=date("h:ia d/j/y"); $result=MYSQL_QUERY("INSERT INTO shoutbox (artist_name,name,message,time)". "VALUES ('$artist_name','$name', '$message','$time')");}?>[/code]You do not have to insert a null value into an autoincrement field. It will fill in by itselfRayRay Quote Link to comment https://forums.phpfreaks.com/topic/20901-help-with-a-simple-shout-box-solved/#findComment-92597 Share on other sites More sharing options...
crzyman Posted September 15, 2006 Author Share Posted September 15, 2006 Thank you so very much. Its working great. Quote Link to comment https://forums.phpfreaks.com/topic/20901-help-with-a-simple-shout-box-solved/#findComment-92607 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.