473,396 Members | 1,757 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

[SOLVED] error in php code

sanjay123456
125 100+
Dear friends


Following peace of code for whenever we click for the next botton
then next question will come to database but its not working . some problem in this code so tell me where its wrong ?

[PHP]

*<?php*
session_start();
if (!isset($_SESSION['count']))


$_SESSION['count'] = 1;
if (isset($_POST['submitted'])) {


$con = mysql_connect("localhost","root","123456");


if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("my_db", $con);
$sql="select * from quest where count =
$_SESSION['count']";$r=mysql_query($sql);


if (!r)
{
die('Error: ' . mysql_error());
exit();


}


while($row = mysql_fetch_array($r))
{*?>**<h3><p* style="color: #0000ff"*>**<?php* echo
$row['que'];*?>**<table* border='0'*><tr><td* valign='top'*><input*
type='radio' name='quiz' value='4' */></td><td>**<?php* echo
$row['op1'];*?><br></td></tr>**<tr><td* valign='top'*><input*
type='radio' name='quiz' value='3' */></td><td>**<?php* echo
$row['op2'];*?><br></td></tr>**<tr><td* valign='top'*><input*
type='radio' name='quiz' value='2' */></td><td>**<?php* echo
$row['op3'];*?><br></td></tr>**<tr><td* valign='top'*><input*
type='radio' name='quiz' value='1' */></td><td>**<?php* echo
$row['op4'];*?>**<br></td></tr>**</table>**<br></p></h3>*
*<?php*


}mysql_close($con)


echo 'This is question no. '.$_SESSION['count'];
$_SESSION['count'] += 1;

}*?>*


*<!DOCTYPE *HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"*>*
*<html><head><title>*Questionnaire*</title></head>*
*<body>*
*<form* name="myform" method="POST" action="*<?php* echo
$_SERVER['PHP_SELF']; *?>*"*>*
*<input* type="submit" VALUE="Click here for the next question *<?php*
echo $_SESSION['count']; *?>*" */>*
*<input* type="hidden" name="submitted" value="1" */>*
*</form></body></html>*



[/PHP]


sanjay
Oct 30 '06 #1
4 1176
ronverdonk
4,258 Expert 4TB
What are all those asterisks (about 100) doing in the code. If you try to run that, it is logical it doesn't work!

By the way, I see that you have started this new thread while it is really a continuation of the thread at http://www.thescripts.com/forum/thread555608.html
Now what are you trying to accomplish with having 2 threads for the same problem?
The sample that was provided was tested and worked. So it must be in your MySQL code or display code because that was not included in the sample.

Ronald :cool:
Oct 30 '06 #2
sanjay123456
125 100+
sir

sorry for unwanted asterstic

Real code r following


[PHP]



<?php

session_start();

if (!isset($_SESSION['count']))

$_SESSION['count'] = 1;

if (isset($_POST['submitted'])) {


$con = mysql_connect("localhost","root","123456");

if (!$con)
{
die('Could not connect: ' . mysql_error());
}

mysql_select_db("my_db", $con);

$sql="select * from quest where count = $_SESSION['count']";
$r=mysql_query($sql);


if (!r)
{
die('Error: ' . mysql_error());
exit();
}

while($row = mysql_fetch_array($r))
{
?>
<h3><p style="color: #0000ff">
<?php echo $row['que'];
?>
<table border='0'><tr><td valign='top'><input type='radio' name='quiz' value='4' /></td><td>
<?php echo $row['op1'];
?><br></td></tr>
<tr><td valign='top'><input type='radio' name='quiz' value='3' /></td><td>
<?php echo $row['op2'];
?><br></td></tr>
<tr><td valign='top'><input type='radio' name='quiz' value='2' /></td><td>
<?php echo $row['op3'];
?><br></td></tr>
<tr><td valign='top'><input type='radio' name='quiz' value='1' /></td><td>
<?php echo $row['op4'];
?>
<br></td></tr>
</table>
<br></p></h3>

<?php
}
mysql_close($con)

echo 'This is question no. '.$_SESSION['count'];
$_SESSION['count'] += 1;
}
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html><head><title>Questionnaire</title></head>

<body>

<form name="myform" method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?>">

<input type="submit" VALUE="Click here for the next question <?php echo $_SESSION['count']; ?>" />

<input type="hidden" name="submitted" value="1" />

</form></body></html>


[/PHP]


sanjay
Oct 31 '06 #3
ronverdonk
4,258 Expert 4TB
The first error that springs in the eye is the select statement you use. It should be [php]$sql="select * from quest where count = " . $_SESSION['count'];[/php]

Ronald :cool:
Oct 31 '06 #4
sanjay123456
125 100+
Sir
A very very thanks to u problem is solved.

sanjay
Oct 31 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Geoff Turner | last post by:
Morning all, Below is a piece of code to deal with a deliberate error. Can someboby explain why, in run mode, 'errhandler' is not reached, but the error is caught by the standard error handler,...
4
by: Bill Cohagan | last post by:
I'm writing a console app in c# and am encountering a strange problem. I'm trying to use redirection of the standard input stream to read input from a (xml) file. The following code snippet is from...
1
by: Jim Christiano | last post by:
Everyone, In order to promote code reuse, I've setup a web control (.ascx) in a standalone vs.net project. I can then reference this project in any web application. The trick is to setup a...
1
by: P Cooper | last post by:
(Posted in multiple groups...Apologies) Why does the error below occur whenever the statement Request.BinaryRead(Request.TotalBytes) is executed for uploads larger than 100K? I thought the 100K...
8
by: Al Reynolds | last post by:
Afternoon, In an earlier thread (http://tinyurl.com/5v4aa), I described a problem I was having which was rather bizarrely solved by changing the line: "inputbox.value = numq+ag-cw-cc;" to:...
5
by: Tammy | last post by:
Hi, I have an aspx app which needs to post data to a form and read the response. I am confused on whether I should be using the get_url using "POST" method or the post_url using "GET" method. ...
3
by: Olivogt | last post by:
Hello, I was just puting an application on the web server but it did not work as usual... - I do develop on my notebook and move released applications to the Web server - both have Sql Server...
2
by: Richard Lionheart | last post by:
Hi All, I generated a WebForm and created a Virtual Directory for it IIS. But I got an error message (shown below) saying something like my app lacked appropriate privileges. David Wang...
1
by: petdoc | last post by:
Hi Folks, I am trying to find the most perplexing bug I have had in a vb.net app to date. Here is some code: Dim Data as Short Data = Me.ReadPMAPDigits(pmOffsets.APIAS)
6
by: Jeff | last post by:
Hey (and thank you for reading my post) In visual web developer 2005 express edition I've created a simple website project.. At this website I want users who register to be able to upload a...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.