PHP - Mysql_fetch_assoc No Longer Works??
Hi, I have tried to merge two queries into one however a piece of code keeps coming up with an error: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource. It relates to this. I cant see it doesn't work and I have tried around 10 different options but this is the nearest I can get. Can anyone advise me what the problem is and why this no longer works please? while($row = mysql_fetch_assoc($myQuery)) <?php ini_set('display_errors', 1); error_reporting(-1); if( isSet($_GET['description'])) $description = $_GET['description']; if(isSet($_GET['price'])) $price = explode('-',$_GET['price']); $low = (int)$price[0]; $high = (int)$price[1]; ($myQuery = "SELECT * FROM productfeed WHERE 1 . if(isset($description)) ' AND if description = '. $description; if(isset($price)) ' AND if price = '. $price; . "); while($row = mysql_fetch_assoc($myQuery)) { $id = $row['id']; $image = $row['awImage']; $link = $row['link']; $description = $row['description']; $fulldescription = $row['fulldescription']; $price = $row['price']; $fulldescription = substr("$fulldescription", 0, 400); echo "<div class='productdisplayshell'> <div class='productdisplayoutline'> <div class='productborder'><center> <a href='$link' target='_blank'><img src='$image' width=\"95%\" /></a> </center> </div></div> <div class='productdescriptionoutline'> <div class='productdescriptionbox'> <a href='$link' target='_blank' >$description</a> </div> <div class='productfulldescriptionbox'>$fulldescription</div> </div> <div class='productpriceoutline'> <div class='productpricebox'> <center>&#163; $price</center> </div> <div class='productbuybutton'> <center><a href='$link' target='_blank' ><img src=/images/buybutton.png /></a></center> </div> </div> </div>"; } Similar TutorialsI'm sure there is a very simple fix to this problem. I have an image uploader in the backend of my site. Since moving hosts this no longer works. The PHP is if((!empty($_FILES["indeximage"]))) { $indeximagename = basename($_FILES['indeximage']['name']); $indeximagenew = $_SERVER['DOCUMENT_ROOT'] . '/images/uploaded/index/' . $indeximagename; if (!file_exists($indeximagenew)) { if ((move_uploaded_file($_FILES['indeximage']['tmp_name'], $indeximagenew)) === true) { echo $indeximagename; echo ' was successfully uploaded.'; }else { echo 'Unable to move'; echo $indeximagename; echo ' into the right folder.'; } }else { echo 'You did not upload an index image.'; } } I'm guessing the problem is with the document root part. $indeximagenew echos /var/www/vhosts/webaddress.co.uk/httpdocs/images/uploaded/index/imagename.jpg The actual actual address of the image, when on the site, is http://www.webaddress.co.uk/images/uploaded/index/imagename.jpg Any help would be great! So this script did work in previous versions oh php but in php5 I get the error, "Sorry, uploaded images must be of type jpg or jpeg, (not )." So it looks like it's not recognizing my file as a jpeg?? Any contributions towards a fix are GREATLY appreciated!!! If there are clean, nice (EASY) php5 scripts available for this simple image uploading and thumbnail creation I would consider starting this over. //Listing page code: echo "<form name=\"addCat\" enctype=\"multipart/form-data\" action=\"preview.php\" method=\"post\">"; <INPUT type="file" name="pic1" size="50" value=""> <INPUT type="file" name="pic2" size="50" value=""> <INPUT type="file" name="pic3" size="50" value=""> <INPUT type="file" name="pic4" size="50" value=""> <input type="submit" value="Upload Images"> //preview.php page code: $pic1 = $_FILES['pic1']; $pic2 = $_FILES['pic2']; $pic3 = $_FILES['pic3']; $pic4 = $_FILES['pic4']; function ResizeImage($im,$maxwidth,$maxheight,$name){ $width = imagesx($im); $height = imagesy($im); if(($maxwidth && $width > $maxwidth) || ($maxheight && $height > $maxheight)){ if($maxwidth && $width > $maxwidth){ $widthratio = $maxwidth/$width; $RESIZEWIDTH=true; } if($maxheight && $height > $maxheight){ $heightratio = $maxheight/$height; $RESIZEHEIGHT=true; } if($RESIZEWIDTH && $RESIZEHEIGHT){ if($widthratio < $heightratio){ $ratio = $widthratio; }else{ $ratio = $heightratio; } }elseif($RESIZEWIDTH){ $ratio = $widthratio; }elseif($RESIZEHEIGHT){ $ratio = $heightratio; } $newwidth = $width * $ratio; $newheight = $height * $ratio; if(function_exists("imagecopyresampled")){ $newim = imagecreatetruecolor($newwidth, $newheight); imagecopyresampled($newim, $im, 0, 0, 0, 0, $newwidth, $newheight, $width, $height); }else{ $newim = imagecreate($newwidth, $newheight); imagecopyresized($newim, $im, 0, 0, 0, 0, $newwidth, $newheight, $width, $height); } ImageJpeg (($newim),$name . ".jpg"); ImageDestroy ($newim); }else{ ImageJpeg ($im,$name . ".jpg"); } } // Set up some variables flush(); set_time_limit(210); // set process page limit to 3.5 minutes $maxfilesize = "102400"; //# individual file size limit - in bytes (102400 bytes = 100KB) $path="2012images"; $thumbpath="thumbs"; // two data pulls to rename images - would be easier to have a permanent counter...fix later $mysql[getpicname] = mysql_query("select pic from picname"); $z = mysql_fetch_array($mysql[getpicname]); $new_filename=$z[pic]; $new_z[pic]=$z[pic]+$total_pics; if(@mysql_query("UPDATE picname SET pic = '$new_z[pic]' ")) echo ""; // Create thumbnail from imgurl and store in thumbs // Height to reszie image to (in pixels) $RESIZEHEIGHT=200; // Width to reszie image to (in pixels) $RESIZEWIDTH=200; //thumbnail to thumbs folder, named same as 1st image $FILENAME=$thumbpath."/".$new_filename; $thumb_name=$thumbpath."/".$new_filename.".jpg"; // create a thumbnail from the first image only $im = imagecreatefromjpeg($_FILES['pic1']['tmp_name']); if($im) { if(file_exists("$pic_1.jpg")) { unlink("$pic_1.jpg"); } if (ResizeImage($im,$RESIZEWIDTH,$RESIZEHEIGHT,$FILENAME)) ImageDestroy ($im); } //now upload the images..... for ($i=1;$i<5;$i++) { //check if blank or image $xpic="pic".$i; if (($$xpic<>"none") and ($$xpic<>"")) { // check if jpg $cert1 = "image/pjpeg"; //jpg $cert2 = "image/jpeg"; //jpg (for MAC) $xtype =$HTTP_POST_FILES[$xpic]['type']; $xsize =$HTTP_POST_FILES[$xpic]['size']; if (($xtype <> $cert1) AND ($xtype <> $cert2)) { echo "<DIV class=\"errorsubheading\"><br><br>Alert - Missing or Invalid Information</DIV><br>"; echo "<DIV class=\"requiredtext\">Sorry, uploaded images must be of type jpg or jpeg, (not $xtype).</DIV><BR>"; echo "<BR><br><br>"; include ("footer.php"); exit(); } if ($xsize > $maxfilesize) { echo "<DIV class=\"errorsubheading\"><br><br>Alert - Missing or Invalid Information</DIV><br>"; echo "<DIV class=\"requiredtext\">Sorry, uploaded images must be under the maximum size requirements.</DIV><BR>"; echo "<BR><br><br>"; include ("footer.php"); exit(); } else { // upload to server $dest=$path."/".$new_filename.".jpg"; If (move_uploaded_file($$xpic, $dest)) { $photo[$i]=$dest; $new_filename+=1; } else { echo "<DIV class=\"errorsubheading\"><br><br>Alert - Upload Failed!</DIV><br>"; echo "<BR><br><br>"; include ("footer.php"); exit(); } // upload sucessful } // end type check } // end check if blank } I am receiving this error: Code: [Select] Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in /home/shannon/public_html/booter/inc/classes/class.db.php on line 17 For the function: Code: [Select] function fetch_array($query) { $array = mysql_fetch_assoc($query); return $array; } Why would I receive that error, if I am just passing a variable? Not a resource or boolean? Thanks. Is there any way that I can get mysql_fetch_assoc only to run once? Here is my code: Code: [Select] $query = mysql_query("SELECT * FROM items ORDER BY id DESC"); while ($row = mysql_fetch_assoc($query)) { $id = $row['id']; } Im having a problem coding for our project . here's the code Code: [Select] <?php $value = $_POST['p']; $host="localhost"; $username="root"; $password=""; $db_name="dbquiz"; mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $value = stripslashes($value); $value = mysql_real_escape_string($value); $sql='SELECT * FROM `'. $value .'` ORDER BY RAND() LIMIT 100'; $result=mysql_query($sql) or die(mysql_error()); if(result){ while($row = mysql_fetch_assoc($result)) { $q = $row['question']; $c1= "" .$row['choice1']; $c2 ="" .$row['choice2']; $c3 ="" .$row['choice3']; $c4 ="" .$row['choice4']; $a ="".$row['answer']; $questions[] = array($q,$c1,$c2,$c3,$c4,$a); } } include_once("makequiz.php"); ?> AND FOR THE makequiz Code: [Select] <?php if (isset($_POST['sent'])) { for ($i=0;$i<count($questions);$i++) { echo($questions[$i][0]." - "); if ($_POST['q'.$i]=="c") { echo("<b>Correct!</b><br>\n"); $score++; } else { echo("<b>Wrong!</b><br>\n"); } } $percent = number_format(($score/count($questions))*100,2,".",","); echo("<br>".$score." out of ".count($questions)." (".$percent."% right)<br>\n"); } else { echo("<form action=\"#\" method=\"post\">\n"); echo("<input type=\"hidden\" name=\"sent\">\n"); for ($i=0;$i<count($questions);$i++) { echo("<b>".$questions[$i][0]."</b><br><br>\n"); if ($questions[$i][5]==1) { echo("<input type=\"radio\" name=\"q".$i."\" value=\"c\"> ".$questions[$i][1]."<br>\n"); } else { echo("<input type=\"radio\" name=\"q".$i."\" value=\"w\"> ".$questions[$i][1]."<br>\n"); } if ($questions[$i][5]==2) { echo("<input type=\"radio\" name=\"q".$i."\" value=\"c\"> ".$questions[$i][2]."<br>\n"); } else { echo("<input type=\"radio\" name=\"q".$i."\" value=\"w\"> ".$questions[$i][2]."<br>\n"); } if ($questions[$i][5]==3) { echo("<input type=\"radio\" name=\"q".$i."\" value=\"c\"> ".$questions[$i][3]."<br>\n"); } else { echo("<input type=\"radio\" name=\"q".$i."\" value=\"w\"> ".$questions[$i][3]."<br>\n"); } if ($questions[$i][5]==4) { echo("<input type=\"radio\" name=\"q".$i."\" value=\"c\"> ".$questions[$i][4]."<br><br>\n"); } else { echo("<input type=\"radio\" name=\"q".$i."\" value=\"w\"> ".$questions[$i][4]."<br><br>\n"); } } echo("<input type=\"submit\" value=\"Am I Right?!\">"); } ?> When you run the first code.. it's working but when i clicked the submit button this error keeps on showing and i dont know why.. "Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in " can someone help me fix this problem pls? thanks in advance. Not sure what I am doing wrong: Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /public_html/lq/index.php on line 12 $schedule = "LQ"; include('/public_html/en/header_staff.php'); include("connect.php"); $page = $_SERVER["SERVER_NAME"]; $who = explode(".", $page); $sql = "select * from rp_staff WHERE schedule = $schedule"; $rpstaff = mysql_query($sql); while ($row = mysql_fetch_assoc($rpstaff)) { $alt = $row['dj']; $name = $row['name']; $city = $row['city']; $state = $row['state']; $country = $row['country']; $artists = $row['artists']; $about = $row['about']; $genre = $row['genrev']; $position = $row['position']; } Code: [Select] $sql = "select * from user_info where us_name='$username' and md5(us_pass)='$userpass'"; $result=mysql_query($sql); $row = mysql_fetch_assoc($result); $count=mysql_num_rows($result); But it is giving error : arning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in C:\...\verify.php on line 19 I am not getting why it is so Following is the simple code to print name of states. However it doesn't print "Alabama" or in short it misses id=1.Can someone please point out my mistake or tell me why won't it print Alabama and ignoring id = 1 ? While debugging i found out it starts from id= 2. Code - Code: [Select] <?php $sql = "SELECT * FROM state"; $result = mysql_query($sql); ?> <SELECT NAME="state"> <OPTION value="">Select State</option> <?php while($arrayRow = mysql_fetch_assoc($result)) { $strA = $arrayRow["id"]; $strB = $arrayRow["state"]; echo "<option value=\"$strB\">$strB</option>\n"; }?> </SELECT> Sql table image - Okay, I had a similar problem before.
$users = mysql_query("SELECT * FROM users"); while($users = mysql_fetch_assoc($users)){ echo "<tr><td><p><a href='users.php?id={$users['user_id']}'>{$users['user_name']}</a></p></td><td>{$users['user_clan']}</td><td>{$users['troop_donations']}</td></tr>"; } Would both of the below snippets do the same job, if so why are both ways taught in text books, can one method do somthing that the other cannot? mysql_fetch_array($result, MYSQL_ASSOC)) And... mysql_fetch_assoc($result) mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\eclipse\test\mysql.php on line 14 this is the error I get if I comment out the if statements. With the If statements I get "query failed" I have to assume the problem is with $extractQuery or $extract ... I just am at a loss for what the problem could be thanks Code: [Select] $connect = mysql_connect("localhost", "root", "") or die(mysql_error()); mysql_select_db("Pickem", $connect) or die(mysql_error()); //extract data from key table $extractQuery = "SELECT * FROM key "; $extract = mysql_query($extractQuery, $connect); if ($extract) { if (mysql_numrows($extract)) { echo $extract; print_r(mysql_fetch_assoc($extract)); } else { echo "no results found"; } } else { echo "query failed"; } I have the following code Code: [Select] $hidden_client_id_query = mysql_query("SELECT id from `pdp_client_info` WHERE lead_id='$post_lead_id'"); $hidden_client_id=mysql_fetch_assoc($hidden_client_id_query); $this->view->hidden_client_id=$hidden_client_id['id']; I get the following error for the above code. I wonder where I am wrong. I am getting the $post_lead_id as expected. Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean i get this error Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\website\viewvideos.php on line 25 Code: [Select] $addviews = $views + 1; $query = mysql_query("UPDATE headlines SET views='$addviews' WHERE id=$viewid"); $rows = mysql_fetch_assoc($query); i dont get whats wrong I cannot retrieve my records from my table, neither can I display them on my website. I do not even get any errors when I run the script on my site. Any help or tips would be greatly appreciated. My current php script is: // connection to database server $db_selected = mysql_select_db('database1', $dbc); if (!$db_selected) { die ('Can\'t use database1 : ' . mysql_error()); } $query = "SELECT * FROM chesstable ORDER BY chapter, lastname"; $result = mysql_query($query) or die('Could not connect' . mysql_error()); echo mysql_num_rows($result); If (!$result) { $message = 'Invalid query: ' . mysql_error(); $message = 'Whole query: ' . $query; die ($message); } while($row = mysql_fetch_assoc($result)) { echo $row['firstname'] . " " . $row['lastname'] . $row['chapter']; } mysql_free_result($result); mysql_close($dbc); ?> I got this code at the top: Code: [Select] <?php require_once("configuration.php"); $uid = $_GET['uid']; ?> And another main one: Code: [Select] <?php if(isset($_GET['uid'])) { $d = ""; $query = mysql_query("SELECT `username`,`level`,`email,`,`alevel`,`tester` FROM `users` WHERE `id`='$uid'"); if(!mysql_num_rows($query)) echo "No user."; while($d = mysql_fetch_assoc($query)) { ?>   <b>Username:</b> <?php echo $d['username']; ?> <br />   <b>Level:</b> <?php echo $d['level']; ?> <br />   <b>Email:</b> <?php echo $d['email']; ?> <br />   <b>Admin level:</b> <?php echo $d['alevel']; ?> <br />   <b>Tester:</b> <?php echo $d['tester']; ?> <?php } } ?> </font> </div> </center> Now I get this error: Code: [Select] Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\learning\viewuser.php on line 20 No user. Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\learning\viewuser.php on line 22 How can I fix it? Can I use the data fetched with the mysql_fetch_assoc command more than once? What I'm trying to do is query a MySQL DB, and print a list of the results by gender. So far I've only been able to do it by querying the DB twice, and I know there's got to be a more efficient way. I think I should be able to go through the array once, print all the males, then go through the array again and print all the females. But I'm stumped as to how to do it. Here's basically what I'm doing to get my results: Code: [Select] $cxn=mysqli_connect("localhost","username","password","table_name") or die ("Could not connect to database"); $query= "SELECT * FROM blah blah blah"; $result=mysqli_query($cxn,$query) or die ("Couldn't execute query."); while ( $row = mysqli_fetch_assoc($result)) { extract($row); IF ($gender == 'M') { echo "Here is my data for Males"; } } I basically want to re-run the WHILE statement, but check for $gender == 'F', without having to re-run the $result=mysqli_query command again. But when I do that, nothing is displayed and the script ends. Is it just a matter of moving a pointer to the beginning of an array or something similar? Thanks in advance. Thank you for looking into this! I need to use result from mysql query twice or more on a page Should I do this: $sql = mysql_query("SQL"); while ($row = mysql_fetch_assoc($sql)) CODE ... while ($row = mysql_fetch_assoc($sql)) CODE2 OR should I keep result of a query in an array and use FOREACH instead? My concern is performance. Ok, I made some changes to my code (change in variable names only) and now it doesn't seem to work. Here is the code. <?php if ($_REQUEST['postal'] != "" && $_REQUEST['lbs'] != "") { $postal = $_REQUEST['postal']; $lbs = $_REQUEST['lbs']; $type = $_REQUEST['type']; if ($type == "splist") { $ztype = "cansp_zone" ; $lbstype = "sp"; } else { $ztype = "canmp_zone"; $lbstype = "mp"; } $qP1 = "SELECT * FROM " . $dbprefix . "_canzones WHERE canzone_postal = '$postal' "; $which = $handle_db2; $rsP1 = mysql_query($qP1,$which); if (mysql_num_rows($rsP1) > 0) { $row1 = mysql_fetch_array($rsP1); extract($row1); $prov = trim($canzone_prov); $zone = trim($canzone_zone); $dzone = $ztype.$zone; $dlbs = "can" . $lbstype . "_lbs"; $query = "SELECT $dzone FROM " . $dbprefix . "_can" . $type . " WHERE $dlbs = '$lbs' "; $which = $handle_db2; $result = mysql_query ($query,$which); $row = mysql_fetch_array($result); $dzone = $row[0]; $qP3 = "SELECT * FROM settings WHERE storeid = '$dbprefix' "; $which = $handle_db2; $rsP3 = mysql_query($qP3,$which); $row3 = mysql_fetch_array($rsP3); extract($row3); $taxsetting = trim($taxsetting); $gst = trim($gst); $pst = trim($pst); $hst = trim($hst); $cp_fuelcharge = trim($cp_fuelcharge); $cp_markup = trim($cp_markup); include("./inc/taxcalc.php"); include("./inc/markcalc.php"); ./inc/markcalc.php is as follows: <?php if ($cp_markup != "") { $cp_mark = ($dzone * ($cp_markup / 100)); When I output $cp_mark, it comes out as the same value as $cp_markup Any ideas? Hi, thanks in advance for any help here. I have a PHP 'contact us' form on my website that recently stopped returning the information that gets entered into the form. I don't know why it's no longer working and was hoping someone here could help. It's worked for the last 4 years and only stopped working within the last week. I still get the email, but none of the information is returned, only blanks. Any ideas? Here's the script I'm using: Code: [Select] <?php /*----------------------*/ /* URL of the site. */ /*----------------------*/ $site_URL = "http://www.Website.com/"; /*----------------------*/ /* Name of the site. */ /*----------------------*/ $site_Name = "Website.com"; /*----------------------*/ /* ADMIN email id. */ /*----------------------*/ $admin_from = "webmaster@Website.com"; /*----------------------*/ /* ADMIN email id to which comments are sent. */ /*----------------------*/ $admin_email = "info@Website.com"; $name = $_REQUEST["firstname"]; $lastname = $_REQUEST["lastname"]; $email = $_REQUEST["email"]; $zipcode = $_REQUEST["zipcode"]; $phone = $_REQUEST["phone"]; $message = $_REQUEST["message"]; $subject = "$site_Name has Received your Message"; $sendmessage = "<font face='tahoma, verdana, arial, helvetica' size=2>New Comments Received...<br><br>"; $sendmessage .= "<strong>Name:</strong> $name $lastname<br>"; $sendmessage .= "<strong>Zipcode:</strong> $zipcode<br>"; $sendmessage .= "<strong>Phone:</strong> $phone<br>"; $sendmessage .= "<strong>Email:</strong> <a href='mailto:$email' style='color:#6095cc; text-decoration: none;'>$email</a><br>"; $sendmessage .= "<strong>Message:</strong> $message<br>"; $sendmessage .= "<br><a href='$site_URL' target=_blank>$site_Name</a></font>"; $headers = "Content-Type: text/html; charset=iso-8859-1\n"; // Mime type $headers .="From: $site_Name Registration <$admin_from>\n"; mail($admin_email, $subject, $sendmessage, $headers); $reply_msg = "<font face='tahoma, verdana, arial, helvetica' size=2>Thank you for your comments at $site_Name. We will reply soon!<br>"; $reply_msg .= "<br>- <a href='$site_URL' target=_blank>$site_Name</a></font>"; $headers = "Content-Type: text/html; charset=iso-8859-1\n"; // Mime type $headers .="From: $site_Name<$admin_from>\n"; // send an email to confirm the referer. mail($email, "$site_Name - Your comments have been received!", $reply_msg, $headers); ?> <center> <font face='tahoma, verdana, arial, helvetica' color='#333333'> <h2> <?=$site_Name?> </h2> <p><font size="2" face="Arial, Helvetica, sans-serif"><strong>Please wait while your comments are being sent.</strong>.<br /> If your page does not refresh automatically, <a href="<?=$site_URL?>">Click Here</a>.</font></p> </center> <script language="javascript"> window.location.href = "<?=$site_URL?>"; </script> MOD EDIT: [code] . . . [/code] BBCode tags added. Hello, Im developing simple user registration system with my knowledge.but got this error with this file Code: [Select] <?php //database connection require_once("dbconnection/connect.php"); $success_massage =""; if (isset($_POST['hiddenstudentid'])) $passstudent_id=$_POST['hiddenstudentid']; else $passstudent_id=$_POST['student_id_hidden']; $sql=mysql_query("SELECT * FROM student WHERE StudentID=$passstudent_id"); echo $sql; while ($row=mysql_fetch_assoc($sql)) { $update_nic=$row['NIC']; $update_name=$row['Student_Name']; $update_addr=$row['Address']; $take_bday=$row['Birthday']; echo $take_bday; $update_bday=date('d',strtotime($take_bday)); $update_month=date('m',strtotime($take_bday)); $update_year=date('y',strtotime($take_bday)); $update_tele=$row['Telephone']; $update_email=$row['Email']; } if (isset($_POST['btnupdate'])) { $insert_nic=$_POST['nic_txt']; $insert_name=$_POST['name_txt']; $insert_addr=$_POST['address_txt']; $insert_bday=$_POST['bdate']; $insert_month=$_POST['bmonth']; $insert_year=$_POST['byear']; $insert_tele=$_POST['telephone_txt']; $insert_email=$_POST['email_txt']; $Birthday =date("$insert_year-$insert_month-$insert_bday");//Bday eka $Birthday ta set kereema. $sql="update student set NIC='$insert_nic',Student_Name='$insert_name',Address='$insert_addr',Birthday='$Birthday',Telephone='$insert_tele',Email='$insert_email' where StudentID=$passstudent_id" ; /*(Student_ID,NIC,Student_Name,Address,Birthday,Telephone,Email)values('$student_id','$insert_nic','$insert_name','$insert_addr','$Birthday','$insert_tele','$insert_email')";*/ //echo $sql; $result=mysql_query($sql) or die ("database error"); $success ="Records updated successfully"; $success_massage =$success; header('Location:editdisplay.php'); } if ($_POST['btndelete']=='DELETER') { $delete = "delete from student where StudentID=$passstudent_id"; $result =mysql_query($delete) or die ("data deleting error"); $delete_massage="Record deleted"; //$success_massage = $delete_massage; } if (isset($_POST['btncancel'])) { header ('Location:registration.php'); } ?> <!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>Untitled Document</title> <script type="text/javascript"> function GetConfirmation() { var res=confirm("Are you sure to delete this Student?"); if(res==true) { var btn=document.getElementById("btndelete"); btn.value="DELETER"; // alert ("YES"); document.editForm.submit(); } } </script> </head> <body> <form id="form1" name="form1" method="post" action=""> <table width="406" border="1"> <tr> <td width="149"> </td> <td width="241">Student Registration</td> </tr> <tr> <td>NIC</td> <td><label for="nic_txt"></label> <input type="text" name="nic_txt" id="nic_txt" value="<?php echo $update_nic ?>" /><input type="hidden" name="student_id_hidden" id="student_id_hidden" value="<?php echo $passstudent_id ?>" /> </td> </tr> <tr> <td>Name</td> <td><label for="name_txt"></label> <input type="text" name="name_txt" id="name_txt" value="<?php echo $update_name ?>" /><span style="color:#F00"><?php echo $massage_name?></span></td> </tr> <tr> <td>Address</td> <td><label for="address_txt"></label> <input type="text" name="address_txt" id="address_txt" value="<?php echo $update_addr ?>" /><span style="color:#F00"><?php echo $massage_address?></span></td> </tr> <tr> <td>Birthday</td> <td><label for="bdate"></label> <select name="bdate" id="bdate"> <option selected="selected"><?php echo $update_bday ?></option> <?php for ( $i=1;$i<=31;$i++) {echo '<option>'.$i.'</option>'; } ?> </select> <label for="bmonth"></label> <select name="bmonth" id="bmonth"> <option selected="selected"><?php echo $update_month ?></option> <?php echo '<option>'.'-month-'.'</option>'; for ($b=1;$b<=12;$b++) {echo '<option>'.$b.'</option>'; } ?> </select> <label for="byear"></label> <select name="byear" id="byear" /> <option selected="selected"><?php echo $update_year ?></option> <?php echo '<option>'.'-year-'.'</option>'; for ($b=1960;$b<=2000;$b++) {echo '<option>'.$b.'</option>'; } ?> </select><span style="color:#F00"><?php echo $massage_bday?></span></td> </tr> <tr> <td>Email</td> <td><label for="email_txt"></label> <input type="text" name="email_txt" id="email_txt" value="<?php echo $update_email?>" /></td> </tr> <tr> <td>Telephone</td> <td><label for="telephone_txt"></label> <input type="text" name="telephone_txt" id="telephone_txt" value="<?php echo $update_tele?>"/></td> </tr> <tr> <td> </td> <td><input type="submit" name="btnupdate" id="btnupdate" value="Update" /> <input type="submit" name="btndelete" id="btndelete" value="Delete" onclick="GetConfirmation()" /> <input type="submit" name="btncancel" id="btncancel" value="Cancel" /></td> </tr> </table> <?php echo $success_massage?> </form> </body> </html> got error from these codes in this file Code: [Select] if (isset($_POST['hiddenstudentid'])) $passstudent_id=$_POST['hiddenstudentid']; else $passstudent_id=$_POST['student_id_hidden']; $sql=mysql_query("SELECT * FROM student WHERE StudentID=$passstudent_id"); echo $sql; it is showing this error this this warning error.in here that details from DB will show in form.and im going to edit them from this file. please help me to find the error. |