Jump to content

baldiajaib

Members
  • Posts

    12
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

baldiajaib's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. quite big i must say...about 40000 ++ data inside the database i did what u've suggested..the same error came out without any series of number. i did both: $rowcount2 = mysql_num_rows ($result) or die(mysql_errno()) $rowcount2 = mysql_num_rows ($result) or die(mysql_errno($link)) how do i repair the tables?
  2. this is the first time that i've come across such error. When i tried to refresh my browser to refresh my site, the computer starts eating up my ram, and this error came out about 2 minutes later: Warning: mysql_query() [function.mysql-query]: Unable to save result set in D:\Dropbox\htdocs\bercy\gestion\abonnes_aman\function_search.php on line 64 Fatal error: Maximum execution time of 60 seconds exceeded in D:\Dropbox\htdocs\bercy\gestion\abonnes_aman\function_search.php on line 64 The problem can be solved if i comment out both these part: LINE 64: $result = mysql_query($sql_query) or die(mysql_error()); but, these errors came out: Warning: mysql_fetch_row() expects parameter 1 to be resource, null given in D:\Dropbox\htdocs\bercy\gestion\abonnes_aman\function_search.php on line 65 Warning: mysql_fetch_array() expects parameter 1 to be resource, string given in D:\Dropbox\htdocs\bercy\gestion\abonnes_aman\function_search.php on line 123 <?php include "storescripts/connectdb.php"; //Run Query For Body List---------------------------------SEARCH FORM------------------------------------------------------- $bodylist=""; $sql = mysql_query ( "SELECT * FROM choixorganisme ORDER BY org_id ASC LIMIT 30" ); $rowcount = mysql_num_rows ($sql); if ($rowcount > 0) { while ($row = mysql_fetch_array ($sql)) { $id = $row['org_id']; $body = $row['org_libelle']; $news_id = $row['news_id']; $bodylist .="<option value=\"$id\">" . $body . "</option>" ; } } //Run query for Format list $formatlist=""; $sql2 = mysql_query ( "SELECT distinct `format` FROM `subscriber` WHERE 1" ); $rowcount2 = mysql_num_rows ($sql2); if ($rowcount2 > 0) { while ($row2 = mysql_fetch_array ($sql2)) { $format = $row2['format']; $formatlist .="<option value=\"". $format . "\">" . $format . "</option>" ; } } // --------------------------------------------------PAGINATION(SEARCH RESULT)--------------------------------------------------- // database connection info include "storescripts/connectdb.php"; // find out how many rows are in the table $sql_query = "SELECT * FROM annuser, subscriber"; $result = mysql_query($sql_query) or die(mysql_error()); $r = mysql_fetch_row($result); $numrows = $r[0]; // number of rows to show per page $rowsperpage = 10; // find out total pages $totalpages = ceil($numrows / $rowsperpage); // get the current page or set a default if (isset($_GET['currentpage']) && is_numeric($_GET['currentpage'])) { // cast var as int $currentpage = (int) $_GET['currentpage']; } else { // default page num $currentpage = 1; } // end if // if current page is greater than total pages... if ($currentpage > $totalpages) { // set current page to last page $currentpage = $totalpages; } // end if // if current page is less than first page... if ($currentpage < 1) { // set current page to first page $currentpage = 1; } // end if // the offset of the list, based on current page $offset = ($currentpage - 1) * $rowsperpage; //SHOW FIRST 100 DATA FROM DATABASE TO PAGE AS DEFAULT $annuser_list = ''; $sql_query .= " WHERE annuser.annuser_id = subscriber.annuser_id LIMIT $offset, $rowsperpage"; /*"SELECT * FROM annuser, subscriber WHERE annuser_firstname LIKE '%". $form_name . "%' OR `annuser_lastname` LIKE '%" . $form_name . "%' AND annuser.annuser_id = subscriber.annuser_id LIMIT 10"*/ //echo $sql_query; $result = mysql_query($sql_query) or die(mysql_error()); $rowcount2 = mysql_num_rows ($result) or die (mysql_error()); //ERROR if ($rowcount2 > 0 ) { while ($row2 = mysql_fetch_array ($sql_query)) //ERROR { $annuser_firstName = stripslashes ($row2['annuser_firstname']); $annuser_lastName = stripslashes ($row2['annuser_lastname']); $annuser_email = stripslashes ($row2['annuser_email']); $annuser_dept = stripslashes ($row2['annuser_email']); $annuser_title = stripslashes ($row2['annuser_title']); $annuser_liste = stripslashes ($row2['format']); $annuser_date = stripslashes ($row2['subsc_date']); $annuser_list .= "<tr> <td>" . $annuser_title . " " . $annuser_firstName . " " . $annuser_lastName . " </td> <td>" . $annuser_email . " </td> <td>" . $annuser_dept . " </td> <td>" . $annuser_liste . " </td> <td>" . $annuser_date . " </td></tr>"; } } mysql_close(); //RUN SEARCH if (isset($_GET ['submit_search'])) { $form_name = $_GET['form_name']; $form_body = $_GET['form_dropdown_body']; $form_body = $_GET['form_dropdown_format']; $sql_query .= " WHERE annuser_firstname LIKE '%". $form_name . "%' OR `annuser_lastname` LIKE '%" . $form_name . "%'" ; $rowcount3 = mysql_num_rows ($sql_query); if ($rowcount3 > 0 ) { while ($row3 = mysql_fetch_array($sql)) { $annuser_firstName = stripslashes ($row3['annuser_firstname']); $annuser_lastName = stripslashes ($row3['annuser_lastname']); $annuser_email = stripslashes ($row3['annuser_email']); $annuser_dept = stripslashes ($row3['annuser_email']); $annuser_title = stripslashes ($row3['annuser_title']); $annuser_liste = stripslashes ($row3['format']); $annuser_date = stripslashes ($row3['subsc_date']); $annuser_list .= "<tr> <td>" . $annuser_title . " " . $annuser_firstName . " " . $annuser_lastName . " </td> <td>" . $annuser_email . " </td> <td>" . $annuser_dept . " </td> <td>" . $annuser_liste . " </td> <td>" . $annuser_date . " </td></tr>"; } } } ?> <!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 http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="css/style.css" /> <title>Untitled Document</title> </head> <!-- LIST OUT FORM GENERATED FROM DATABASE--> <table id="table_form" class="table_form" cellpadding="2" cellspacing="3" border="0"> <form id="archive" class="archive" method="get" action="function_search.php"> <tr> <td> Name / Surname </td> <td> Body </td> <td> Format </td> <td> </td> </tr> <tr> <td> <input type="text" id="form_name" name="form_name" size="20"/> </td> <td> <select name="form_dropdown_body" id="form_dropdown_format" name="form_dropdown_format"> <option value="Tous"> Tous </option> <?php echo $bodylist; ?> </select></td> <td> <select name="form_dropdown_format" id="form_dropdown_format" name="form_dropdown_format"> <option value="Tous">Tous</option> <?php echo $formatlist; ?> </select> </td> <td> <input type="submit" id="submit_search" class="submit_search" name="submit_search" value="Rechercher"> </tr> </form> </table> </br></br></br> <table align="center" class="table_list" id="table_list" > <tr> <th> Abonne <img src="images/sort_asc.png" alt="sort ascending" /> <img src="images/sort_dsc.png" alt="sort descending" /> </th> <th> Email <img src="images/sort_asc.png" alt="sort ascending"/> <img src="images/sort_dsc.png" alt="sort descending" /></th> <th> Dept <img src="images/sort_asc.png" alt="sort ascending"/> <img src="images/sort_dsc.png" alt="sort descending" /></th> <th> Liste <img src="images/sort_asc.png" alt="sort ascending" /> <img src="images/sort_dsc.png" alt="sort descending" /></th> <th> Depuis <img src="images/sort_asc.png" alt="sort ascending"/> <img src="images/sort_dsc.png" alt="sort descending" /></th> </tr> <?php //echo $annuser_list_search; ?> <?php echo $annuser_list; ?> </table> <?php //----------------------------------PAGINATION LINKS----------------------------------------------------- // range of num links to show $range = 3; // if not on page 1, don't show back links if ($currentpage > 1) { // show << link to go back to page 1 $arrowWayBack = " <a href='{$_SERVER['PHP_SELF']}?currentpage=1'><<</a> "; // get previous page num $prevpage = $currentpage - 1; // show < link to go back to 1 page $arrowBack = " <a href='{$_SERVER['PHP_SELF']}?currentpage=$prevpage'><</a> "; } // end if // loop to show links to range of pages around current page for ($x = ($currentpage - $range); $x < (($currentpage + $range) + 1); $x++) { // if it's a valid page number... if (($x > 0) && ($x <= $totalpages)) { // if we're on current page... if ($x == $currentpage) { // 'highlight' it but don't make a link $currentPageNumber = " [<b>$x</b>] "; // if not current page... } else { // make it a link $page = " <a href='{$_SERVER['PHP_SELF']}?currentpage=$x'>$x</a> "; } // end else } // end if } // end for // if not on last page, show forward and last page links if ($currentpage != $totalpages) { // get next page $nextpage = $currentpage + 1; // echo forward link for next page $arrowForward = " <a href='{$_SERVER['PHP_SELF']}?currentpage=$nextpage'>></a> "; // echo forward link for lastpage $arrowWayForward = " <a href='{$_SERVER['PHP_SELF']}?currentpage=$totalpages'>>></a> "; } // end if //Show pagination links at the middle of page echo "</br><div align='center'>" . $arrowWayBack, $arrowBack, $currentPageNumber, $page, $arrowForward, $arrowWayForward . "</div>"; /****** end build pagination links ******/ ?>
  3. edited it and it works like a charm...hoever i thought the standard php for joining php was like this example below: $query = "SELECT family.Position, food.Meal ". "FROM family, food ". "WHERE family.Position = food.Position"; anyway thanks man...extremely appreciate your help and time....I almost gave up yesterday....I have another question...how do u exactly read the kohana error? the stack error is used for what?
  4. i'm quite new in kohana 2..ben following a tutorial and error comes out trying to retrieve data from mysql: but error comes out the view page, products.php: <h2>Products</h2> <h3>L33t Products</h3> <table> <tr> <th>Category</th> <th>Product Code</th> <th>Product Description</th> <th>Price</th> <th>Units</th> </tr> <?php foreach ($products as $item): ?> <tr> <td><?php echo html::specialchars($item->cat_description) ?></td> <td><?php echo html::specialchars($item->code) ?></td> <td><?php echo html::specialchars($item->prod_description) ?></td> <td><?php echo number_format(($item->price / 100),2) ?></td> <td>per</td> <td><?php echo html::specialchars($item->unit) ?></td> </tr> <?php endforeach ?> </table> the controller, products.php: <?php defined('SYSPATH') or die('No direct script access.'); class Products_Controller extends Website_Controller { public function index() { $this -> template -> title = 'Products::Kohana 2.0 Tutorial'; $this -> template -> content = new View ('pages/products'); $products = new Product_Model; // instantiate the model //result set is assigned to a variable called $products in the view $this->template->content->products = $products->browse(); /*Line is used to check database whether DB connection is working or not echo Kohana::debug($this->db->list_fields('categories'));*/ } } the model, product.php : <?php defined ('SYSPATH') or die ('No Direct Script Access'); class Product_Model extends Model { public function __construct() { parent::__construct(); } public function browse() { return $this->db->select ( 'categories.description AS cat_description', 'products.code', 'products.description AS prod_description', 'products.price', 'products.unit' ) ->from('categories') ->join('products', 'categories.id = products.cat_id') ->orderby (array('categories.description' => 'ASC', 'products.code' => 'ASC')) ->get(); } } cracked my head for few days now....thanks in advance guys!
  5. $result2 = mysql_query("SELECT id FROM guestlist LIMIT $offset, $rowsperpage"); Correction: $result2 = mysql_query("SELECT * FROM guestlist LIMIT $offset, $rowsperpage"); thanks for reading guys...solved it
  6. I followed a pagination tutorial in PHPFreaks...edited it using my own preference and this error comes out Notice: Undefined index: name in C:\xampp\htdocs\guestbook\index.php on line 105 Notice: Undefined index: url in C:\xampp\htdocs\guestbook\index.php on line 106 Notice: Undefined index: email in C:\xampp\htdocs\guestbook\index.php on line 107 Notice: Undefined index: message in C:\xampp\htdocs\guestbook\index.php on line 108 Notice: Undefined index: date in C:\xampp\htdocs\guestbook\index.php on line 109 Thanks for reading guys...really appreciate your help <?php ob_start(); ///*//Error reporting $ebits = ini_get('error_reporting'); error_reporting($ebits ^ E_NOTICE); //*/ // Connect to the MySQL database include "scripts/connect_to_mysql.php"; // Sends data to database = GUESTBOOK if (isset($_POST['submit'])) { $name = mysql_real_escape_string($_POST['guest_name']); $email = mysql_real_escape_string($_POST['guest_email']); $url = mysql_real_escape_string($_POST['guest_url']); $message = mysql_real_escape_string($_POST['guest_message']); // See if that e-mail is an identical match to another e-mail in the system $sql = mysql_query("SELECT email FROM guestlist WHERE email='$email' LIMIT 1"); $productMatch = mysql_num_rows($sql); if ($productMatch > 0) { echo 'Sorry, e-mail already registered, <a href="index.php">click here</a>'; exit(); } // Store data into the database $sql = mysql_query("INSERT INTO guestlist (name, email, url, message, ip, date) VALUES('$name','$email','$url','$message', '$guest_ip', now())") or die (mysql_error()); $pid = mysql_insert_id(); // Place image in the folder $newname = "$pid.png"; move_uploaded_file( $_FILES['file']['tmp_name'], "image/$newname"); header("location: index.php"); exit(); } //Retrieve guest's IP address $ipaddress=$_SERVER["REMOTE_ADDR"]; echo "Your IP ADDRESS: ". $ipaddress; // --------------------------------------------------PAGINATION--------------------------------------------------------------------------- // database connection info include "scripts/connect_to_mysql.php"; // find out how many rows are in the table $sql = "SELECT COUNT(*) FROM guestlist"; $result = mysql_query($sql) or trigger_error("SQL", E_USER_ERROR); $r = mysql_fetch_row($result); $numrows = $r[0]; // number of rows to show per page $rowsperpage = 10; // find out total pages $totalpages = ceil($numrows / $rowsperpage); // get the current page or set a default if (isset($_GET['currentpage']) && is_numeric($_GET['currentpage'])) { // cast var as int $currentpage = (int) $_GET['currentpage']; } else { // default page num $currentpage = 1; } // end if // if current page is greater than total pages... if ($currentpage > $totalpages) { // set current page to last page $currentpage = $totalpages; } // end if // if current page is less than first page... if ($currentpage < 1) { // set current page to first page $currentpage = 1; } // end if // the offset of the list, based on current page $offset = ($currentpage - 1) * $rowsperpage; // get the info from the db // while there are rows to be fetched... // Display guest list from database $guest_list = ""; $result2 = mysql_query("SELECT id FROM guestlist LIMIT $offset, $rowsperpage"); $productCount2 = mysql_num_rows($result2); echo "<br/>".$productCount2; if ($productCount2 > 0) { while($row = mysql_fetch_array($result2)){ $id = $row["id"]; $name = $row["name"]; $url = $row["url"]; $email = $row["email"]; $message = $row["message"]; $date = strftime("%b %d, %Y", strtotime($row["date"])); // Generate list into a organized table $guest_list .= "<tr> <td style=\"width:200px\" rowspan=\"3\"> <img src=\"image/" . $id . ".png\" alt=\"' . $name . '\" width=\"120\" border=\"0\" /></td> </tr> <tr> <td style=\"width:280px\"><strong><font size=\"2\">$name</font></strong><br/> <font size=\"1\">$email</font><br/> <font size=\"1\"><a href=\"$url\">$url</a></font><br/> <em><font size=\"1\"><p align=\"left\"> <font size=\"1\"><p align=\"left\">Added $date</p></font></em></td> <td style=\"width:700px\" align=\"center\"> $message </td></tr><br /> <tr> <td style=\"width:200px\"></td> <td style=\"width:700px\"></td></tr>"; } } else { $guest_list = '<div style="font-family:verdana,arial,helvetica;color:#FFFFFF;">Guest List is Empty! No one visited you!</font>'; } /****** build the pagination links ******/ // range of num links to show $range = 3; // if not on page 1, don't show back links if ($currentpage > 1) { // show << link to go back to page 1 echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=1'><<</a> "; // get previous page num $prevpage = $currentpage - 1; // show < link to go back to 1 page echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$prevpage'><</a> "; } // end if // loop to show links to range of pages around current page for ($x = ($currentpage - $range); $x < (($currentpage + $range) + 1); $x++) { // if it's a valid page number... if (($x > 0) && ($x <= $totalpages)) { // if we're on current page... if ($x == $currentpage) { // 'highlight' it but don't make a link echo " [<b>$x</b>] "; // if not current page... } else { // make it a link echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$x'>$x</a> "; } // end else } // end if } // end for // if not on last page, show forward and last page links if ($currentpage != $totalpages) { // get next page $nextpage = $currentpage + 1; // echo forward link for next page echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$nextpage'>></a> "; // echo forward link for lastpage echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$totalpages'>>></a> "; } // end if /****** end build pagination links ******/ ?> <!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 http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Guestbook v1.0</title> <link rel="stylesheet" href="css/style.css" type="text/css" media="screen" /> <script type="text/javascript" language="javascript"> function validateMyForm ( ) { var isValid = true; if ( document.guestbook.guest_name.value == "" ) { alert ( "Please type your Name" ); isValid = false; } else if ( document.guestbook.guest_email.value == "" ) { alert ( "Please type your Email" ); isValid = false; } else if ( document.guestbook.guest_url.value == "" ) { alert ( "Please type your URL" ); isValid = false; } else if ( document.guestbook.guest_message.value == "" ) { alert ( "Please type your message" ); isValid = false; } return isValid; } </script> </head> <body> <div align="center" id="head" name="head"> <h1> GUESTBOOK </h1> </div> <div align="center"> <h2><em>Guest list</em></h2> </div> <table border="0" align="center" id='table2' name='table2'> <?php echo "<font color=\"#000000\" size=\"2px\">$guest_list</font>"; ?> </table> </br></br> <div id="body" name="body" align="center"> <form enctype="multipart/form-data" action="index.php" name="guestbook" id="guestbook" method="post"> <table align="center" width="90%" cellpadding="6" cellspacing="0" id="table" name="table"> <tr> <td> <div align="right">Name:</div></td> <td> <input type="text" name="guest_name" id="guest_name" size="50" /></tr> <tr> <td> <div align="right">E-Mail:</div></td> <td> <input type="text" name="guest_email" id="guest_email" size="50" /></tr> <tr> <td> <div align="right">URL:</div></td> <td> <input type="text" name="guest_url" id="guest_url" size="50" /></tr> <tr> <td> <div align="right">Photo:</div></td> <td><label> <div align="left"> <input type="file" name="file" id="file" /> <!-- <font size="1"><i>(Limit upload of 120px X 120px)</i></font>--> </div> </label></tr> <tr> <td> Message:</td> <td> <div align="left"> <textarea name="guest_message" id="guest_message" cols="40" rows="10"></textarea> </div></td> </tr> <tr><td></td> <td> <div align="left"> <input type="submit" name="submit" id="submit" value="Submit" onclick="javascript:return validateMyForm();" /> </div></td></tr> </table> </form> </div> </body> <?php ob_flush(); ?> </html>
  7. i did some corrections, but still not working <?php ob_start(); session_start(); ?> <!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> [bad html removed] This webpage is created by Aman bin Awaludin © 2011. All Rights Reserved --> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <style type="text/css"> [bad html removed] .style1 {font-family: arial, verdana, sans-serif; font-size:13px;} .style3 {font-family: arial, verdana, sans-serif; font-weight: bold; } .style5 { font-family: arial, verdana, sans-serif; font-style: italic; font-size: 12px; } .style6 { color: #FF0000; font-weight: bold; } .style7 {font-size: 12px; font-family: arial, verdana, sans-serif;} --> </style> <script type="text/javascript"> [bad html removed] function MM_swapImgRestore() { //v3.0 var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc; } function MM_preloadImages() { //v3.0 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array(); var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++) if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}} } function MM_findObj(n, d) { //v4.01 var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) { d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n]; for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); if(!x && d.getElementById) x=d.getElementById(n); return x; } function MM_swapImage() { //v3.0 var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3) if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];} } //--> </script> <script type="text/javascript" language="javascript"> [bad html removed] function validateprojek ( ) { var isValid = true; if (( !form.q1[0].checked) && ( !form.q1[1].checked) && ( !form.q1[2].checked) && ( !form.q1[3].checked) && ( !form.q1[4].checked)) { alert ( "Soalan 1 Tidak Dijawab!" ); isValid = false; } else if (( !form.q2[0].checked) && ( !form.q2[1].checked) && ( !form.q2[2].checked) && ( !form.q2[3].checked) && ( !form.q2[4].checked)) { alert ( "Soalan 2 Tidak Dijawab!" ); isValid = false; } else if (( !form.q3[0].checked) && ( !form.q3[1].checked) && ( !form.q3[2].checked) && ( !form.q3[3].checked) && ( !form.q3[4].checked)) { alert ( "Soalan 3 Tidak Dijawab!" ); isValid = false; } else if (( !form.q4[0].checked) && ( !form.q4[1].checked) && ( !form.q4[2].checked) && ( !form.q4[3].checked) && ( !form.q4[4].checked)) { alert ( "Soalan 4 Tidak Dijawab!" ); isValid = false; } else if (( !form.q5[0].checked) && ( !form.q5[1].checked) && ( !form.q5[2].checked) && ( !form.q5[3].checked) && ( !form.q5[4].checked)) { alert ( "Soalan 5 Tidak Dijawab!" ); isValid = false; } else if (( !form.q6[0].checked) && ( !form.q6[1].checked) && ( !form.q6[2].checked) && ( !form.q6[3].checked) && ( !form.q6[4].checked)) { alert ( "Soalan 6 Tidak Dijawab!" ); isValid = false; } else if (( !form.q7[0].checked) && ( !form.q7[1].checked) && ( !form.q7[2].checked) && ( !form.q7[3].checked) && ( !form.q7[4].checked)) { alert ( "Soalan 7 Tidak Dijawab!" ); isValid = false; } else if (( !form.q8[0].checked) && ( !form.q8[1].checked) && ( !form.q8[2].checked) && ( !form.q8[3].checked) && ( !form.q8[4].checked)) { alert ( "Soalan 8 Tidak Dijawab!" ); isValid = false } else if (( !form.q9[0].checked) && ( !form.q9[1].checked) && ( !form.q9[2].checked) && ( !form.q9[3].checked) && ( !form.q9[4].checked)) { alert ( "Soalan 9 Tidak Dijawab!" ); isValid = false } return isValid; } //--> </script> </head> <body onload="MM_preloadImages('image/next2.png')"> <?php if (isset ($_SESSION['resultX1'])) { echo '<p align="center" class="style7">Penilaian Kategori Projek bagi Projek ini telah dibuat. Soalan dan Jawapan Penilaian akan dipaparkan sebentar lagi..</p>'; header("Refresh: 3; url=\"jawapanprojek.php\""); exit(); } if (!isset ($_SESSION['namaProjek'])){ echo '<p align="center" class="style7">Anda belum lagi membuat pilihan memulakan Penilaian Baru. Sila pastikan borang di sebelah di isikan dahulu..</p>'; //header("Refresh: 3; url=\"index.php\""); exit(); } if (!isset($_SESSION["manager"])) { header("location: Login.php"); exit(); } //Be sure to check that this manager SESSION value is in fact in the database $managerID = preg_replace('#[^0-9]#i', '', $_SESSION["id"]); // filter everything but numbers and letters $manager = preg_replace('#[^A-Za-z0-9]#i', '', $_SESSION["manager"]); // filter everything but numbers and letters $password = preg_replace('#[^A-Za-z0-9]#i', '', $_SESSION["password"]); // filter everything but numbers and letters //Run mySQL query to be sure that this person is an admin and that their password session var equals the database information //Connect to the MySQL database include "storescripts/connect_to_mysql.php"; $sql = mysql_query("SELECT * FROM company WHERE companyId='$managerID' AND username='$manager' AND password='$password' LIMIT 1"); // query the person // ------- MAKE SURE PERSON EXISTS IN DATABASE --------- $existCount = mysql_num_rows($sql); // count the row nums if ($existCount == 0) { // evaluate the count echo "Your login session data is not on record in the database. Go to <a href='Login.php'>Login Page</a>"; exit(); } $namaprojek2 = $_SESSION['namaProjek']; $id3 = $_SESSION['id']; $id4 = $_SESSION['idprojek']; $sql3 = mysql_query("SELECT * FROM project WHERE projectname = '$namaprojek2' AND companyId = '$id3' AND projectId = '$id4'"); $displayoutput2 = mysql_num_rows($sql3); if ($displayoutput2 > 0) { while($row2 = mysql_fetch_array($sql3)){ $a1 = $row2['q1']; $a2 = $row2['q2']; $a3 = $row2['q3']; $a4 = $row2['q4']; $a5 = $row2['q5']; $a6 = $row2['q6']; $a7 = $row2['q7']; $a8 = $row2['q8']; $a9 = $row2['q9']; $a10 = $row2['q10']; $a11 = $row2['q11']; $a12 = $row2['q12']; $a13 = $row2['q13']; $a14 = $row2['q14']; $a15 = $row2['q15']; $a16 = $row2['q16']; } } ob_flush(); ?> [bad html removed]IFRAME SCROLLING USING JAVASCRIPT & ARROW IMAGE--> <div id="staticbuttons" style="position:absolute;"> <a href="javascript:" onMouseOver="myspeed=-thespeed" onMouseOut="myspeed=0"><img src="image/arrowup.png" border="0"></a><br> <a href="javascript:" onMouseOver="myspeed=thespeed" onMouseOut="myspeed=0"><img src="image/arrowdown.png" border="0"></a></div> <script> var Hoffset=50 //Enter buttons' offset from right edge of window (adjust depending on images width) var Voffset=80 //Enter buttons' offset from bottom edge of window (adjust depending on images height) var thespeed=4 //Enter scroll speed in integer (Advised: 1-3) var ieNOTopera=document.all&&navigator.userAgent.indexOf("Opera")==-1 var myspeed=0 var ieHoffset_extra=document.all? 15 : 0 var cross_obj=document.all? document.all.staticbuttons : document.getElementById? document.getElementById("staticbuttons") : document.staticbuttons function iecompattest(){ return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body } function positionit(){ var dsocleft=document.all? iecompattest().scrollLeft : pageXOffset var dsoctop=document.all? iecompattest().scrollTop : pageYOffset var window_width=ieNOTopera? iecompattest().clientWidth+ieHoffset_extra : window.innerWidth+ieHoffset_extra var window_height=ieNOTopera? iecompattest().clientHeight : window.innerHeight if (document.all||document.getElementById){ cross_obj.style.left=parseInt(dsocleft)+parseInt(window_width)-Hoffset+"px" cross_obj.style.top=dsoctop+parseInt(window_height)-Voffset+"px" } else if (document.layers){ cross_obj.left=dsocleft+window_width-Hoffset cross_obj.top=dsoctop+window_height-Voffset } } function scrollwindow(){ window.scrollBy(0,myspeed) } function initializeIT(){ positionit() if (myspeed!=0){ scrollwindow() } } if (document.all||document.getElementById||document.layers) setInterval("initializeIT()",20) /** ALLOWS MOUSEWHEEL SCROLLING * It must react to delta being more/less than zero. */ function handle(delta) { var d=delta*-10; window.scrollBy(0,d); } /** Event handler for mouse wheel event. */ function wheel(event){ var delta = 0; if (!event) /* For IE. */ event = window.event; if (event.wheelDelta) { /* IE/Opera. */ delta = event.wheelDelta/120; /** In Opera 9, delta differs in sign as compared to IE. */ if (window.opera) delta = -delta; } else if (event.detail) { /** Mozilla case. */ /** In Mozilla, sign of delta is different than in IE. * Also, delta is multiple of 3. */ delta = -event.detail/3; } /** If delta is nonzero, handle it. * Basically, delta is now positive if wheel was scrolled up, * and negative, if wheel was scrolled down. */ if (delta) handle(delta); /** Prevent default actions caused by mouse wheel. * That might be ugly, but we handle scrolls somehow * anyway, so don't bother here.. */ if (event.preventDefault) event.preventDefault(); event.returnValue = false; } /** Initialization code. * If you use your own event management code, change it as required. */ if (window.addEventListener) /** DOMMouseScroll is for mozilla. */ window.addEventListener('DOMMouseScroll', wheel, false); /** IE/Opera. */ window.onmousewheel = document.onmousewheel = wheel; </script> <div align="center"><img src="image/4.png" width="800" height="94" /></div> </br></br> <div align="center"> <p class="style3">Kerapian Takrifan: Objektif dan Justifikasi Projek</p> <p align="center"><span class="style7">SKALA</span><span class="style5">: <span class="style6">4</span> = Cemerlang; <strong class="style6">3</strong> = Baik; <strong class="style6">2</strong> = Purata; <strong class="style6">1</strong> = Bawah Purata; <strong class="style6">0</strong> = Tidak Boleh Diterima</span></p> <form id="projek" name="projek" method="post" action="projek2.php" > <table width="694" border="0"> <tr bgcolor="#666666"> <td width="61"><div align="center" class="style3">Bil.</div></td> <td width="439"><div align="center" class="style3">Pengukur</div></td> <td width="180"><div align="center" class="style3">Skala</div></td> </tr> <tr bgcolor="#E7F3F1"> <td><div align="center" class="style1">1</div></td> <td><p class="style1">Objektif projek spesifik serta jelas (iaitu objektif projek menyatakan dengan tepat dan jelas apa yang hendak dicapai).</p></td> <td class="style1"><input type="radio" name="q1" id="q1" value="4"> 4 <input type="radio" name="q1" id="q1" value="3"> 3 <input type="radio" name="q1" id="q1" value="2"> 2 <input type="radio" name="q1" id="q1" value="1"> 1 <input type="radio" name="q1" id="q1" value="0"> 0</td> </tr> <tr bgcolor="#E7F3F1"> <td class="style1"><div align="center">2</div></td> <td><p class="style1">Objektif projek boleh diukur (iaitu objektif projek menyatakan ukuran yang hendak dicapai).</p></td> <td class="style1"><input type="radio" name="q2" id="q2" value="4"> 4 <input type="radio" name="q2" id="q2" value="3"> 3 <input type="radio" name="q2" id="q2" value="2"> 2 <input type="radio" name="q2" id="q2" value="1"> 1 <input type="radio" name="q2" id="q2" value="0"> 0</td> </tr> <tr bgcolor="#E7F3F1"> <td class="style1"><div align="center">3</div></td> <td class="style1"><p>Objektif projek boleh dicapai dalam masa yang ditetapkan.</p></td> <td class="style1"><input type="radio" name="q3" id="q3" value="4"> 4 <input type="radio" name="q3" id="q3" value="3"> 3 <input type="radio" name="q3" id="q3" value="2"> 2 <input type="radio" name="q3" id="q3" value="1"> 1 <input type="radio" name="q3" id="q3" value="0"> 0</td> </tr> <tr bgcolor="#E7F3F1"> <td class="style1"><div align="center">4</div></td> <td class="style1"><p>Objektif projek realistik.</p></td> <td class="style1"><input type="radio" name="q4" id="q4" value="4"> 4 <input type="radio" name="q4" id="q4" value="3"> 3 <input type="radio" name="q4" id="q4" value="2"> 2 <input type="radio" name="q4" id="q4" value="1"> 1 <input type="radio" name="q4" id="q4" value="0"> 0</td> </tr> <tr bgcolor="#E7F3F1"> <td class="style1"><div align="center">5</div></td> <td class="style1"><p>Objektif projek dipersetujui oleh <em>stakeholders </em>utama<em>.</em></p></td> <td class="style1"><input type="radio" name="q5" id="q5" value="4"> 4 <input type="radio" name="q5" id="q5" value="3"> 3 <input type="radio" name="q5" id="q5" value="2"> 2 <input type="radio" name="q5" id="q5" value="1"> 1 <input type="radio" name="q5" id="q5" value="0"> 0</td> </tr> <tr bgcolor="#E7F3F1"> <td class="style1"><div align="center">6</div></td> <td class="style1"><p>Justifikasi menumpu kepada matlamat organisasi yang hendak dicapai.</p></td> <td class="style1"><input type="radio" name="q6" id="q6" value="4">4 <input type="radio" name="q6" id="q6" value="3"> 3 <input type="radio" name="q6" id="q6" value="2"> 2 <input type="radio" name="q6" id="q6" value="1"> 1 <input type="radio" name="q6" id="q6" value="0"> 0</td> </tr> <tr bgcolor="#E7F3F1"> <td class="style1"><div align="center">7</div></td> <td class="style1"><p>Justifikasi menyatakan kepentingan atau faedah yang akan diperoleh dengan terlaksananya projek </p></td> <td class="style1"><input type="radio" name="q7" id="q7" value="4"> 4 <input type="radio" name="q7" id="q7" value="3"> 3 <input type="radio" name="q7" id="q7" value="2"> 2 <input type="radio" name="q7" id="q7" value="1"> 1 <input type="radio" name="q7" id="q7" value="0"> 0</td> </tr> <tr bgcolor="#E7F3F1"> <td class="style1"><div align="center">8</div></td> <td class="style1"><p>Justifikasi menyatakan peningkatan kemahiran kakitangan dengan terlaksananya projek. </p></td> <td class="style1"><input type="radio" name="q8" id="q8" value="4"> 4 <input type="radio" name="q8" id="q8" value="3"> 3 <input type="radio" name="q8" id="q8" value="2"> 2 <input type="radio" name="q8" id="q8" value="1"> 1 <input type="radio" name="q8" id="q8" value="0"> 0</td> </tr> <tr bgcolor="#E7F3F1"> <td class="style1"><div align="center">9</div></td> <td class="style1"><p>Kesemua kerja yang terangkum dalam projek ditakrif dengan jelas.</p></td> <td class="style1"><input type="radio" name="q9" id="q9" value="4"> 4 <input type="radio" name="q9" id="q9" value="3"> 3 <input type="radio" name="q9" id="q9" value="2"> 2 <input type="radio" name="q9" id="q9" value="1"> 1 <input type="radio" name="q9" id="q9" value="0"> 0</td> </tr> </table> </br></br> <input name="submit" type="submit" value="Teruskan" onclick="javascript:return validateprojek();"/> </form> </body> </html>
  8. I have a problem here..My page is a set of question (survey). here there are 9 sets of questions which are all RADIO BUTTONS. i used JavaScript to validate to make sure that EVERY BUTTON @ QUESTIONS IS CHECKED. The problem is the validation does not run even though I left one @ several question unchecked <?php ob_start(); session_start(); ?> <!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> [bad html removed] This webpage is created by Aman bin Awaludin © 2011. All Rights Reserved --> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <style type="text/css"> [bad html removed] .style1 {font-family: arial, verdana, sans-serif; font-size:13px;} .style3 {font-family: arial, verdana, sans-serif; font-weight: bold; } .style5 { font-family: arial, verdana, sans-serif; font-style: italic; font-size: 12px; } .style6 { color: #FF0000; font-weight: bold; } .style7 {font-size: 12px; font-family: arial, verdana, sans-serif;} --> </style> <script type="text/javascript"> [bad html removed] function MM_swapImgRestore() { //v3.0 var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc; } function MM_preloadImages() { //v3.0 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array(); var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++) if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}} } function MM_findObj(n, d) { //v4.01 var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) { d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n]; for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); if(!x && d.getElementById) x=d.getElementById(n); return x; } function MM_swapImage() { //v3.0 var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3) if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];} } //--> </script> <script type="text/javascript" language="javascript"> [bad html removed] function validateprojek ( ) { var isValid = true; if (( !form.q1[0].checked) && ( !form.q1[1].checked) && ( !form.q1[2].checked) && ( !form.q1[3].checked) && ( !form.q1[4].checked)) { alert ( "Soalan 1 Tidak Dijawab!" ); isValid = false; } else if (( form.q2[0].checked) && ( form.q2[1].checked) && ( form.q2[2].checked) && ( form.q2[3].checked) && ( form.q2[4].checked)) { alert ( "Soalan 2 Tidak Dijawab!" ); isValid = false; } else if (( form.q3[0].checked) && ( form.q3[1].checked) && ( form.q3[2].checked) && ( form.q3[3].checked) && ( form.q3[4].checked)) { alert ( "Soalan 3 Tidak Dijawab!" ); isValid = false; } else if (( form.q4[0].checked) && ( form.q4[1].checked) && ( form.q4[2].checked) && ( form.q4[3].checked) && ( form.q4[4].checked)) { alert ( "Soalan 4 Tidak Dijawab!" ); isValid = false; } else if (( form.q5[0].checked) && ( form.q5[1].checked) && ( form.q5[2].checked) && ( form.q5[3].checked) && ( form.q5[4].checked)) { alert ( "Soalan 5 Tidak Dijawab!" ); isValid = false; } else if (( form.q6[0].checked) && ( form.q6[1].checked) && ( form.q6[2].checked) && ( form.q6[3].checked) && ( form.q6[4].checked)) { alert ( "Soalan 6 Tidak Dijawab!" ); isValid = false; } else if (( form.q7[0].checked) && ( form.q7[1].checked) && ( form.q7[2].checked) && ( form.q7[3].checked) && ( form.q7[4].checked)) { alert ( "Soalan 7 Tidak Dijawab!" ); isValid = false; } else if (( form.q8[0].checked) && ( form.q8[1].checked) && ( form.q8[2].checked) && ( form.q8[3].checked) && ( form.q8[4].checked)) { alert ( "Soalan 8 Tidak Dijawab!" ); isValid = false } else if (( form.q9[0].checked) && ( form.q9[1].checked) && ( form.q9[2].checked) && ( form.q9[3].checked) && ( form.q9[4].checked)) { alert ( "Soalan 9 Tidak Dijawab!" ); isValid = false } return isValid; } //--> </script> </head> <body onload="MM_preloadImages('image/next2.png')"> <?php if (isset ($_SESSION['resultX1'])) { echo '<p align="center" class="style7">Penilaian Kategori Projek bagi Projek ini telah dibuat. Soalan dan Jawapan Penilaian akan dipaparkan sebentar lagi..</p>'; header("Refresh: 3; url=\"jawapanprojek.php\""); exit(); } if (!isset ($_SESSION['namaProjek'])){ echo '<p align="center" class="style7">Anda belum lagi membuat pilihan memulakan Penilaian Baru. Sila pastikan borang di sebelah di isikan dahulu..</p>'; //header("Refresh: 3; url=\"index.php\""); exit(); } if (!isset($_SESSION["manager"])) { header("location: Login.php"); exit(); } //Be sure to check that this manager SESSION value is in fact in the database $managerID = preg_replace('#[^0-9]#i', '', $_SESSION["id"]); // filter everything but numbers and letters $manager = preg_replace('#[^A-Za-z0-9]#i', '', $_SESSION["manager"]); // filter everything but numbers and letters $password = preg_replace('#[^A-Za-z0-9]#i', '', $_SESSION["password"]); // filter everything but numbers and letters //Run mySQL query to be sure that this person is an admin and that their password session var equals the database information //Connect to the MySQL database include "storescripts/connect_to_mysql.php"; $sql = mysql_query("SELECT * FROM company WHERE companyId='$managerID' AND username='$manager' AND password='$password' LIMIT 1"); // query the person // ------- MAKE SURE PERSON EXISTS IN DATABASE --------- $existCount = mysql_num_rows($sql); // count the row nums if ($existCount == 0) { // evaluate the count echo "Your login session data is not on record in the database. Go to <a href='Login.php'>Login Page</a>"; exit(); } $namaprojek2 = $_SESSION['namaProjek']; $id3 = $_SESSION['id']; $id4 = $_SESSION['idprojek']; $sql3 = mysql_query("SELECT * FROM project WHERE projectname = '$namaprojek2' AND companyId = '$id3' AND projectId = '$id4'"); $displayoutput2 = mysql_num_rows($sql3); if ($displayoutput2 > 0) { while($row2 = mysql_fetch_array($sql3)){ $a1 = $row2['q1']; $a2 = $row2['q2']; $a3 = $row2['q3']; $a4 = $row2['q4']; $a5 = $row2['q5']; $a6 = $row2['q6']; $a7 = $row2['q7']; $a8 = $row2['q8']; $a9 = $row2['q9']; $a10 = $row2['q10']; $a11 = $row2['q11']; $a12 = $row2['q12']; $a13 = $row2['q13']; $a14 = $row2['q14']; $a15 = $row2['q15']; $a16 = $row2['q16']; } } ob_flush(); ?> [bad html removed]IFRAME SCROLLING USING JAVASCRIPT & ARROW IMAGE--> <div id="staticbuttons" style="position:absolute;"> <a href="javascript:" onMouseOver="myspeed=-thespeed" onMouseOut="myspeed=0"><img src="image/arrowup.png" border="0"></a><br> <a href="javascript:" onMouseOver="myspeed=thespeed" onMouseOut="myspeed=0"><img src="image/arrowdown.png" border="0"></a></div> <script> var Hoffset=50 //Enter buttons' offset from right edge of window (adjust depending on images width) var Voffset=80 //Enter buttons' offset from bottom edge of window (adjust depending on images height) var thespeed=4 //Enter scroll speed in integer (Advised: 1-3) var ieNOTopera=document.all&&navigator.userAgent.indexOf("Opera")==-1 var myspeed=0 var ieHoffset_extra=document.all? 15 : 0 var cross_obj=document.all? document.all.staticbuttons : document.getElementById? document.getElementById("staticbuttons") : document.staticbuttons function iecompattest(){ return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body } function positionit(){ var dsocleft=document.all? iecompattest().scrollLeft : pageXOffset var dsoctop=document.all? iecompattest().scrollTop : pageYOffset var window_width=ieNOTopera? iecompattest().clientWidth+ieHoffset_extra : window.innerWidth+ieHoffset_extra var window_height=ieNOTopera? iecompattest().clientHeight : window.innerHeight if (document.all||document.getElementById){ cross_obj.style.left=parseInt(dsocleft)+parseInt(window_width)-Hoffset+"px" cross_obj.style.top=dsoctop+parseInt(window_height)-Voffset+"px" } else if (document.layers){ cross_obj.left=dsocleft+window_width-Hoffset cross_obj.top=dsoctop+window_height-Voffset } } function scrollwindow(){ window.scrollBy(0,myspeed) } function initializeIT(){ positionit() if (myspeed!=0){ scrollwindow() } } if (document.all||document.getElementById||document.layers) setInterval("initializeIT()",20) /** ALLOWS MOUSEWHEEL SCROLLING * It must react to delta being more/less than zero. */ function handle(delta) { var d=delta*-10; window.scrollBy(0,d); } /** Event handler for mouse wheel event. */ function wheel(event){ var delta = 0; if (!event) /* For IE. */ event = window.event; if (event.wheelDelta) { /* IE/Opera. */ delta = event.wheelDelta/120; /** In Opera 9, delta differs in sign as compared to IE. */ if (window.opera) delta = -delta; } else if (event.detail) { /** Mozilla case. */ /** In Mozilla, sign of delta is different than in IE. * Also, delta is multiple of 3. */ delta = -event.detail/3; } /** If delta is nonzero, handle it. * Basically, delta is now positive if wheel was scrolled up, * and negative, if wheel was scrolled down. */ if (delta) handle(delta); /** Prevent default actions caused by mouse wheel. * That might be ugly, but we handle scrolls somehow * anyway, so don't bother here.. */ if (event.preventDefault) event.preventDefault(); event.returnValue = false; } /** Initialization code. * If you use your own event management code, change it as required. */ if (window.addEventListener) /** DOMMouseScroll is for mozilla. */ window.addEventListener('DOMMouseScroll', wheel, false); /** IE/Opera. */ window.onmousewheel = document.onmousewheel = wheel; </script> <div align="center"><img src="image/4.png" width="800" height="94" /></div> </br></br> <div align="center"> <p class="style3">Kerapian Takrifan: Objektif dan Justifikasi Projek</p> <p align="center"><span class="style7">SKALA</span><span class="style5">: <span class="style6">4</span> = Cemerlang; <strong class="style6">3</strong> = Baik; <strong class="style6">2</strong> = Purata; <strong class="style6">1</strong> = Bawah Purata; <strong class="style6">0</strong> = Tidak Boleh Diterima</span></p> <form id="projek" name="projek" method="post" action="projek2.php" > <table width="694" border="0"> <tr bgcolor="#666666"> <td width="61"><div align="center" class="style3">Bil.</div></td> <td width="439"><div align="center" class="style3">Pengukur</div></td> <td width="180"><div align="center" class="style3">Skala</div></td> </tr> <tr bgcolor="#E7F3F1"> <td><div align="center" class="style1">1</div></td> <td><p class="style1">Objektif projek spesifik serta jelas (iaitu objektif projek menyatakan dengan tepat dan jelas apa yang hendak dicapai).</p></td> <td class="style1"><input type="radio" name="q1" id="q1" value="4"> 4 <input type="radio" name="q1" id="q1" value="3"> 3 <input type="radio" name="q1" id="q1" value="2"> 2 <input type="radio" name="q1" id="q1" value="1"> 1 <input type="radio" name="q1" id="q1" value="0"> 0</td> </tr> <tr bgcolor="#E7F3F1"> <td class="style1"><div align="center">2</div></td> <td><p class="style1">Objektif projek boleh diukur (iaitu objektif projek menyatakan ukuran yang hendak dicapai).</p></td> <td class="style1"><input type="radio" name="q2" id="q2" value="4"> 4 <input type="radio" name="q2" id="q2" value="3"> 3 <input type="radio" name="q2" id="q2" value="2"> 2 <input type="radio" name="q2" id="q2" value="1"> 1 <input type="radio" name="q2" id="q2" value="0"> 0</td> </tr> <tr bgcolor="#E7F3F1"> <td class="style1"><div align="center">3</div></td> <td class="style1"><p>Objektif projek boleh dicapai dalam masa yang ditetapkan.</p></td> <td class="style1"><input type="radio" name="q3" id="q3" value="4"> 4 <input type="radio" name="q3" id="q3" value="3"> 3 <input type="radio" name="q3" id="q3" value="2"> 2 <input type="radio" name="q3" id="q3" value="1"> 1 <input type="radio" name="q3" id="q3" value="0"> 0</td> </tr> <tr bgcolor="#E7F3F1"> <td class="style1"><div align="center">4</div></td> <td class="style1"><p>Objektif projek realistik.</p></td> <td class="style1"><input type="radio" name="q4" id="q4" value="4"> 4 <input type="radio" name="q4" id="q4" value="3"> 3 <input type="radio" name="q4" id="q4" value="2"> 2 <input type="radio" name="q4" id="q4" value="1"> 1 <input type="radio" name="q4" id="q4" value="0"> 0</td> </tr> <tr bgcolor="#E7F3F1"> <td class="style1"><div align="center">5</div></td> <td class="style1"><p>Objektif projek dipersetujui oleh <em>stakeholders </em>utama<em>.</em></p></td> <td class="style1"><input type="radio" name="q5" id="q5" value="4"> 4 <input type="radio" name="q5" id="q5" value="3"> 3 <input type="radio" name="q5" id="q5" value="2"> 2 <input type="radio" name="q5" id="q5" value="1"> 1 <input type="radio" name="q5" id="q5" value="0"> 0</td> </tr> <tr bgcolor="#E7F3F1"> <td class="style1"><div align="center">6</div></td> <td class="style1"><p>Justifikasi menumpu kepada matlamat organisasi yang hendak dicapai.</p></td> <td class="style1"><input type="radio" name="q6" id="q6" value="4">4 <input type="radio" name="q6" id="q6" value="3"> 3 <input type="radio" name="q6" id="q6" value="2"> 2 <input type="radio" name="q6" id="q6" value="1"> 1 <input type="radio" name="q6" id="q6" value="0"> 0</td> </tr> <tr bgcolor="#E7F3F1"> <td class="style1"><div align="center">7</div></td> <td class="style1"><p>Justifikasi menyatakan kepentingan atau faedah yang akan diperoleh dengan terlaksananya projek </p></td> <td class="style1"><input type="radio" name="q7" id="q7" value="4"> 4 <input type="radio" name="q7" id="q7" value="3"> 3 <input type="radio" name="q7" id="q7" value="2"> 2 <input type="radio" name="q7" id="q7" value="1"> 1 <input type="radio" name="q7" id="q7" value="0"> 0</td> </tr> <tr bgcolor="#E7F3F1"> <td class="style1"><div align="center">8</div></td> <td class="style1"><p>Justifikasi menyatakan peningkatan kemahiran kakitangan dengan terlaksananya projek. </p></td> <td class="style1"><input type="radio" name="q8" id="q8" value="4"> 4 <input type="radio" name="q8" id="q8" value="3"> 3 <input type="radio" name="q8" id="q8" value="2"> 2 <input type="radio" name="q8" id="q8" value="1"> 1 <input type="radio" name="q8" id="q8" value="0"> 0</td> </tr> <tr bgcolor="#E7F3F1"> <td class="style1"><div align="center">9</div></td> <td class="style1"><p>Kesemua kerja yang terangkum dalam projek ditakrif dengan jelas.</p></td> <td class="style1"><input type="radio" name="q9" id="q9" value="4"> 4 <input type="radio" name="q9" id="q9" value="3"> 3 <input type="radio" name="q9" id="q9" value="2"> 2 <input type="radio" name="q9" id="q9" value="1"> 1 <input type="radio" name="q9" id="q9" value="0"> 0</td> </tr> </table> </br></br> <input name="submit" type="submit" value="Teruskan" onclick="javascript:return validateprojek();"/> </form> </body> </html> Googled everything, tried several tutorials but no good..thanks in advance guys
  9. good idea friend, i did like what u said. where i took the companyID from the company table --> put it into a $_SESSION['id'] --> when i want to input data into the projectID, i placed the session ID as well, where $id = $_SESSION['id'] and input the companyID that was logging in into the project table..it really works. before that, here's the error and the correction: error $query = "INSERT INTO project(x1,x2,x3) VALUES ('$exone','$extwo','$exthree')"; correction $query = " INSERT INTO project (projectId, x1, x2, x3, companyId) VALUES (2, '$exone','$extwo','$exthree','$id')"; Problem solved in a different method, thanks to u guys. really appreciate it. by the way, is it possible for me to auto_increment the projectID without putting the value of 2 in my correction $query? how does the aut_increment work? do i just leave the space for projectID empty?
  10. ok so i've deleted all data and tried reentering is, but still the same error came out. do u mean that i should add foreign keys in the company_id first before prompting the data from php to mysql?
  11. so does it mean that the null shouldn't be there at the first place?does the foreign key will be auto generated?
  12. I'm currently working on an online project evaluation system which contain 2 tables which are company and project the company table stores the company's information while the project table contains lists of project's score @ grades labelled x1, x2, x3, x4, x5, x6, x7, x8, x9. the aim is to calculate x1, x2, x3 and store it into project table. after processing all the calculation, i then post it into the database. the problem is this error: "Cannot add or update a child row: a foreign key constraint fails (`movedb`.`project`, CONSTRAINT `project_ibfk_1` FOREIGN KEY (`companyId`) REFERENCES `company` (`companyId`) ON DELETE CASCADE ON UPDATE CASCADE)" I've tried various solution that i googled but it seems that al of them are not working... Anyway, thank u for taking the time to read and understand my problem ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ Server version: 5.1.37 CREATE TABLE company ( companyId INT NOT NULL, username VARCHAR(30), password VARCHAR(30), company_name VARCHAR (255), PRIMARY KEY (companyId ) ) TYPE = INNODB; CREATE TABLE project ( projectId INT NOT NULL, x1 DOUBLE, x2 DOUBLE, x3 DOUBLE, x4 DOUBLE, x5 DOUBLE, x6 DOUBLE, x7 DOUBLE, x8 DOUBLE, x9 DOUBLE, companyId INT NOT NULL, PRIMARY KEY(projectId), INDEX (companyId), FOREIGN KEY (companyId) REFERENCES company (companyId) ON DELETE CASCADE ON UPDATE CASCADE ) TYPE = INNODB; company table project table -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- <?php ob_start(); //start session session_start(); if (!isset($_SESSION["manager"])) { header("location: Login.php"); exit(); } //Be sure to check that this manager SESSION value is in fact in the database $managerID = preg_replace('#[^0-9]#i', '', $_SESSION["id"]); // filter everything but numbers and letters $manager = preg_replace('#[^A-Za-z0-9]#i', '', $_SESSION["manager"]); // filter everything but numbers and letters $password = preg_replace('#[^A-Za-z0-9]#i', '', $_SESSION["password"]); // filter everything but numbers and letters //Run mySQL query to be sure that this person is an admin and that their password session var equals the database information //Connect to the MySQL database include "storescripts/connect_to_mysql.php"; $sql = mysql_query("SELECT * FROM company WHERE companyId='$managerID' AND username='$manager' AND password='$password' LIMIT 1"); // query the person // ------- MAKE SURE PERSON EXISTS IN DATABASE --------- $existCount = mysql_num_rows($sql); // count the row nums if ($existCount == 0) { // evaluate the count echo "Your login session data is not on record in the database. Go to <a href='Login.php'>Login Page</a>"; exit(); } //IF POST SUBMIT FROM PROJEK 1 //CALCULATE X1 if ($_POST['submit']) { $_1 = $_POST['q1']; $_2 = $_POST['q2']; $_3 = $_POST['q3']; $_4 = $_POST['q4']; $_5 = $_POST['q5']; $_6 = $_POST['q6']; $_7 = $_POST['q7']; $_8 = $_POST['q8']; $_9 = $_POST['q9']; $k = $_1 + $_2 + $_3 + $_4 + $_5 + $_6 + $_7 + $_8 + $_9; $n = 9*4; $resultX1 = $k/$n; //echo "X1: " . $resultX1 . "</br>"; $_SESSION['resultX1'] = $resultX1; } //IF POST SUBMIT ON THIS PAGE, PROJEK 2 //Calculate X2 & x3 if ($_POST['hantar']) { $_10 = $_POST['q10']; $_11 = $_POST['q11']; $_12 = $_POST['q12']; $j = $_10 + $_11 + $_12; $m = 3*4; $resultX2 = $j/$m; //Calculate X3 $_13 = $_POST['q13']; $_14 = $_POST['q14']; $_15 = $_POST['q15']; $_16 = $_POST['q16']; $p = $_13 + $_14 + $_15 + $_16; $q = 4*4; $resultX3 = $p/$q; //echo "X3: " . $resultX3 . "</br>"; //echo "X2: " . $resultX2 . "</br>"; $_SESSION['resultX2'] = $resultX2; $_SESSION['resultX3'] = $resultX3; $exone = $_SESSION['resultX1']; $extwo = $_SESSION['resultX2']; $exthree = $_SESSION['resultX3']; // INSERTING INFO INTO DATABASE CUSTOMERINFO $query = "INSERT INTO project(x1,x2,x3) VALUES ('$exone','$extwo','$exthree')"; mysql_query($query) or die(mysql_error()); mysql_insert_id(); mysql_close($connection); echo '<span class="style3">Anda telah berjaya menilai Kategori Projek. Tahap Pengurusan Skor Projek akan dipaparkan sebentar lagi..</span>'; header("Refresh: 3; url=\"skopprojek.php\""); //exit(); } ?> -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
×
×
  • 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.