UbH Posted January 25, 2008 Share Posted January 25, 2008 Hi I am working on a polling script but I am running into problems. I have my database setup and table correctly configured but when I try to run this script: <?php <?php include 'Scripts/Connect_to_Database.php'; ?> if(mysql_fetch_object(mysql_query("select s_id from plus_poll_ans where s_id='$s_id'"))){ echo "<a href=view_poll_result.php>View the poll result</a>"; } /* You can keep the parts below inside the else area if you don't want to show the form for the visitors who have already participated in the poll */ $qst_id=1; // Change this ID for a different poll $query=mysql_fetch_object(mysql_query("select * from plus_poll where qst_id=$qst_id")); echo "<form method=post action=poll_displayck.php> <input type=hidden name=qst_id value=$qst_id> <table border='1' cellspacing='0' bordercolor='#ffff00' width='120' id='AutoNumber1'> <tr> <td width='100%' bgcolor='#ffff00'><font face='Verdana' size='2' >$query->qst</font></td> </tr><tr><td width='100%' > <table border='0' cellspacing='0' bordercolor='#111111' width='100%' cellpadding='0'> <tr bgcolor='#f1f1f1'> <td width='10%'><input type='radio' value='$query->opt1' name='opt'></td> <td width='90%'><font face='Verdana' size='2' >$query->opt1</font></td> </tr> <tr> <td width='10%'><input type='radio' value='$query->opt2' name='opt'></td> <td width='90%'><font face='Verdana' size='2' >$query->opt2</font></td> </tr> <tr bgcolor='#f1f1f1'> <td width='10%'><input type='radio' value='$query->opt3' name='opt'></td> <td width='90%'><font face='Verdana' size='2' >$query->opt3</font></td> </tr> <tr> <td width='10%'><input type='radio' value='$query->opt4' name='opt'></td> <td width='90%'><font face='Verdana' size='2' >$query->opt4</font></td> </tr> </table> </td></tr><tr><td width='100%' bgcolor='#ffff00' align=center> <input type=submit value=Submit></form></td></tr> </table> "; /* End of the form displaying the poll question and its four options for selection */ ?> I get an error saying: Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource in /mnt/w0209/d31/s33/b02c2dec/www/mywebsite.com/ray/Scripts/student_polling.php on line 9 As you can see line 9 is if(mysql_fetch_object(mysql_query("select s_id from plus_poll_ans where s_id='$s_id'"))){ So... I am at a loss anyone got any ideas?? Quote Link to comment https://forums.phpfreaks.com/topic/87844-solved-php-polling-script-problems/ Share on other sites More sharing options...
roopurt18 Posted January 26, 2008 Share Posted January 26, 2008 I'm not sure if this is in your actual file, but look at the first two lines: <?php <?php include 'Scripts/Connect_to_Database.php'; ?> Two <?php tags and you exit out of PHP on line 2 with ?>. The syntax highlighting on your post should have given that much away. Quote Link to comment https://forums.phpfreaks.com/topic/87844-solved-php-polling-script-problems/#findComment-449375 Share on other sites More sharing options...
UbH Posted January 26, 2008 Author Share Posted January 26, 2008 Never mind I figured it out. was the fact that I had created a table for the poll questions but didn't make a table for the poll answers hence on line 9 "select s_id from plus_poll_ans" Quote Link to comment https://forums.phpfreaks.com/topic/87844-solved-php-polling-script-problems/#findComment-449377 Share on other sites More sharing options...
UbH Posted January 26, 2008 Author Share Posted January 26, 2008 Sorry about that, no thats not in my actual code was a copy paste error here on the site. Thanks though! UbH Quote Link to comment https://forums.phpfreaks.com/topic/87844-solved-php-polling-script-problems/#findComment-449381 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.