Swole Posted September 30, 2009 Share Posted September 30, 2009 Ok my problem is I'm trying to get this page to pull a random quote from my database and then give the user a option if they like the quote or not. So after the user decides if they like it or not they click a button with whatever choice they made. I want to get it so once they click the button it will send the answer and the quote to another table. My problem is i can get it to work untill I add $sql into the code and then the page stops displaying anything. (Sorry for any grammer or spelling problem. English was never my strongest subject,lol.) <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta content="text/html; charset=utf-8" http-equiv="Content-Type" /> <title>Crushed</title> <style type="text/css"> input#YES { margin-left: 545px; background-color: #FF0000; } input#MAYBE { margin-left: 5px; background-color: #FF0000; } input#NO { margin-left: 5px; background-color: #FF0000; } </style> </head> <body> <?php $user=""; $password=""; $database=""; $connection=mysql_connect('localhost',$user,$password); @mysql_select_db($database) or die( "Unable to select database"); $query="SELECT `question`, `question` FROM `questions` ORDER by rand() LIMIT 1"; $result=mysql_query($query) or die(mysql_error()); $QID = htmlentities(mysql_result($result,$i,"QID")); $question = htmlentities(mysql_result($result,$i,"question")); echo("<blockquote>" . $QID . " <center>" . $question . "</center></blockquote>"); ?> <form action="index.php" method="post"> <input id="YES" name="YES" type="submit" value="YES" /><input id="MAYBE" name="MAYBE" type="submit" value="MAYBE" /><input id="NO" name="NO" type="submit" value="NO" /></form> <?php if(isset($_POST['YES'])){ $sql = } ?> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/176005-solved-sql-help/ Share on other sites More sharing options...
RussellReal Posted September 30, 2009 Share Posted September 30, 2009 maybe try adjusting the syntax <?php if(isset($_POST['YES'])){ $sql = } ?> should probably look something like: <?php if (isset($_POST['YES'])) { $sql = ''; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/176005-solved-sql-help/#findComment-927502 Share on other sites More sharing options...
Swole Posted September 30, 2009 Author Share Posted September 30, 2009 That worked!!! Thanks a bunch... Quote Link to comment https://forums.phpfreaks.com/topic/176005-solved-sql-help/#findComment-927640 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.