[PHP] Maximum execution time exceeded!
hi all, when i am trying to calculate the number of rows with a '0' in a particular column using the following code, it is giving the 'Maximum execution time exceeded' message, eventhough after i gave set_time_limit(60), it didn't worked, infact now it is even worse the browser is getting siezed. $result=mysql_query("select * from mytable"); while ($avgrow=mysql_fetch_array($result)) { $prescene2 = $avgrow["scene2"]; $prescene4 = $avgrow["scene4"]; $prescene5 = $avgrow["scene5"]; $prescene7 = $avgrow["scene7"]; $prescene8 = $avgrow["scene8"]; $prescene9 = $avgrow["scene9"]; $i = 1; while ($prescene2 == 0) { $i=$i+1; } } printf ("Number of zeros=%d",$i); Can any one please help me with this. TIA kalyan __ Do You Yahoo!? Yahoo! Auctions - Buy the things you want at great prices. http://auctions.yahoo.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] if ... else ...
Hi all, I am having 5 rows in a mysql database related to five different users. these rows contains their firstname, lastname and details of scenes 1 to 5(these details are numeric values from 1 to 3). if any of these fields from scenes 1 to 5 are empty that will be detected from the firstname of the user(collected from a form with a filed name 'fname') by opening the database and will be indicated to that user from which scene he got empty fields. here is the code that i wrote works like a champ. $db = mysql_connect ("localhost","myname","password") or die("bUnable to connect to database./b"); mysql_select_db ("nimitztest",$db) or die("bUnable to select database./b"); $result = mysql_query ("select * from mytable order by id",$db); if ($row=mysql_fetch_array($result)) { while ($row=mysql_fetch_array($result)) { $FirstName = $row["firstname"]; if ($fname == $FirstName) { for ($i=1; $i=5; $i++) { $Num[$i] = $row["num$i"]; if ($Num[$i] == '') { printf ("You have to goto Scene$ip"); break; } } } } } But when i include the else statement like below, to indicate an user with all the fields filled up as 'You don't have any thing to fill', this code is giving weird results such as printing like this onto the screen: You don't have anything to fill You have to goto Scene2 You have to goto Scene3 You have to goto Scene4 You have to goto Scene5 for a user with scene2 onwards empty fields. This may be, because of fault in my code or because of misinterpretation of the mysql functions by me. - for ($i=1; $i=5; $i++) { $Num[$i] = $row["num$i"]; if ($Num[$i] == '') { printf ("You have to goto Scene$ip"); } else { printf ("You don't have anything to fillp"); } } -- Please correct me about the mistake i am making over above. TIA Chakravarthy K Sannedhi __ Do You Yahoo!? Yahoo! Auctions - Buy the things you want at great prices. http://auctions.yahoo.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Selecting max(id) of a table
Hello all, I am having a table named 'mytable' of 5 rows in a MySQL database. I tried to print '5' which is the highest row onto the screen. I used the following code for that: $result=mysql_query('select max(id) from mytable'); $max=mysql_result($result); print ('Max id in the table=$max'); But what all i am getting is an error like below: Warning:Wrong parameter count for mysql_result() in /home/httpd/info.php on line xx Max id in the table=$max i am confused about which function to use instead of mysql_result(). please help Chakravarthy K Sannedhi __ Do You Yahoo!? Yahoo! Auctions - Buy the things you want at great prices. http://auctions.yahoo.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] How to avoid submitting twice?
hello all, I am having a form which contains a dropdown listbox and a submit button. The user will choose any number from 1 to 5 and hits the submit button. After this the data that he had selected (1,2,3,4 or 5) enters into a mysql database(this data enters into the row with the latest userid) and a link appears, so that by click that link he can go to next page. I want to avoid the user from submitting his opinion once again if he does it already. Here is the code that i have wrote, which is going logically some where wrong. FYI : opinion and submit are the names of the dropdown listbox and submit buttons. scene1 is the name of the field in the table named testtable into which the data enters(one of 1 to 5) mysql_connect ('localhost','myname','password') or die ('bunable to connect to the database./b'); mysql_select_db ('usertest') or die ('bunable to select the database./b'); if ($submit) { $result = mysql_query("select * from testtable order by userid desc limit 1"); $myrow = mysql_fetch_array ($result); $id = $myrow["userid"]; $query = "update testtable set scene1='$opinion' where userid=$id"; mysql_query ($query); echo "a href=next.phpGo to next page/a"; /* this is the part i am trying to use to avoid him from doing submission second time */ $result=mysql_query("select * from testtable order by userid desc limit 1"); $myrow = mysql_fetch_array ($result); $scene1 = $myrow["scene1"]; if ($scene1 == 1||2||3||4||5) { echo "script language=\"javascript\""; echo "alert(\"You can choose the rating only once\");"; echo "/script"; } } Thanks Chakravarthy K Sannedhi __ Do You Yahoo!? Get email at your own domain with Yahoo! Mail. http://personal.mail.yahoo.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]