Jump to content

[SOLVED] PHP Polling Script Problems


UbH

Recommended Posts

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??

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.