PHP - Help! Warning: Mysql_fetch_row() Expects Parameter 1 To Be Resource
this Nofications appear..
Notice: Undefined index: id in C:\wamp\www\WAR\up3\view.php on line 4 Warning: mysql_fetch_row() expects parameter 1 to be resource, boolean given in C:\wamp\www\WAR\up3\view.php on line 9 invalid id this is my code. <?php require ('dbconnect.php'); // Connect to database $id = $_GET['id']; // ID of entry you wish to view. To use this enter "view.php?id=x" where x is the entry you wish to view. $query = "SELECT data, filetype FROM uploads where uploadid=$id"; //Find the file, pull the filecontents and the filetype $result = MYSQL_QUERY($query); // run the query if($row=mysql_fetch_row($result)) // pull the first row of the result into an array(there will only be one) { $data = $row[0]; // First bit is the data $type = $row[1]; // second is the filename Header( "Content-type: $type"); // Send the header of the approptiate file type, if it's' a image you want it to show as one print $data; // Send the data. } else // the id was invalid { echo "invalid id"; } ?> Similar Tutorials<?php if(isset($_POST['submit'])){ $name = $_POST['name']; } ?> <form method="POST" action="hist1.php"> <br /> <input type="hidden" name="name" value="<?php echo $name ?>" /> <?php $q = mysql_query("SELECT * FROM histact1 ORDER BY RAND() LIMIT 1"); while ($r1 = mysql_fetch_array($q)){ $id = $r1[0]; $question1 = $r1[1]; $opt1 = $r1[3]; $opt2 = $r1[4]; $opt3 = $r1[5]; ?> <div class="Qset" id="q1"><br /><br /> <label class="items">1st Question :</label> <br /> <center> <textarea class="textareaQ" name="question1" readonly><?php echo $question1; ?></textarea> </center> <br /><br /> <p class="marA"> <input type="radio" name="rad1" value="<?php echo $opt1; ?>" /> <label class="lbl"><?php echo $opt1 ?></label><br /> <input type="radio" name="rad1" value="<?php echo $opt2; ?>" /> <label class="lbl"><?php echo $opt2 ?></label><br /> <input type="radio" name="rad1" value="<?php echo $opt3; ?>" /> <label class="lbl"><?php echo $opt3 ?></label><br /> </p> </div> <div class="lr"> <center> <br /><br /><br /><br /> <a class="nxt" href="#q2"><label title="Proceed to 2nd Question">Next</label></a> </center> </div> <br /><br /><br /> <center><hr width="90%" /></center><br /> <?php } ?> <br /><br /> <?php $q = mysql_query("SELECT * FROM histact1 ORDER BY RAND() LIMIT 1"); while ($r1 = mysql_fetch_array($q)){ $id = $r1[0]; $question2 = $r1[1]; $opt1 = $r1[3]; $opt2 = $r1[4]; $opt3 = $r1[5]; ?> <div class="Qset" id="q2"><br /><br /> <label class="items">2nd Question :</label> <br /> <center> <textarea class="textareaQ" name="q2" readonly><?php echo $question2; ?></textarea> </center> <br /><br /> <p class="marA"> <input type="radio" name="rad2" value="<?php echo $opt1; ?>" /> <label class="lbl"><?php echo $opt1 ?></label><br /> <input type="radio" name="rad2" value="<?php echo $opt2; ?>" /> <label class="lbl"><?php echo $opt2 ?></label><br /> <input type="radio" name="rad2" value="<?php echo $opt3; ?>" /> <label class="lbl"><?php echo $opt3 ?></label><br /> </p> </div> <div class="lr"> <center> <br /><br /><br /><br /> <a class="nxt" href="#q1"><label title="Proceed to 1st Question">Back</label></a> | <a class="nxt" href="#q3"><label title="Proceed to 3rd Question">Next</label></a> </center> </div> <br /><br /><br /> <center><hr width="90%" /></center><br /> <?php } ?> <br /><br /> <?php $q = mysql_query("SELECT * FROM histact1 ORDER BY RAND() LIMIT 1"); while ($r1 = mysql_fetch_array($q)){ $id = $r1[0]; $question3 = $r1[1]; $opt1 = $r1[3]; $opt2 = $r1[4]; $opt3 = $r1[5]; ?> <div class="Qset" id="q3"><br /><br /> <label class="items">3rd Question :</label> <br /> <center> <textarea class="textareaQ" name="q3" readonly><?php echo $question3; ?></textarea> </center> <br /><br /> <p class="marA"> <input type="radio" name="rad3" value="<?php echo $opt1; ?>" /> <label class="lbl"><?php echo $opt1 ?></label><br /> <input type="radio" name="rad3" value="<?php echo $opt2; ?>" /> <label class="lbl"><?php echo $opt2 ?></label><br /> <input type="radio" name="rad3" value="<?php echo $opt3; ?>" /> <label class="lbl"><?php echo $opt3 ?></label><br /> </p> </div> <div class="lr"> <center> <br /><br /><br /><br /> <a class="nxt" href="#q2"><label title="Proceed to 2nd Question">Back</label></a> | <a class="nxt" href="#q4"><label title="Proceed to 4th Question">Next</label></a> </center> </div> <br /><br /><br /> <center><hr width="90%" /></center><br /> <?php } ?> <br /><br /> <?php $q = mysql_query("SELECT * FROM histact1 ORDER BY RAND() LIMIT 1"); while ($r1 = mysql_fetch_array($q)){ $id = $r1[0]; $question4 = $r1[1]; $opt1 = $r1[3]; $opt2 = $r1[4]; $opt3 = $r1[5]; ?> <div class="Qset" id="q4"><br /><br /> <label class="items">4th Question :</label> <br /> <center> <textarea class="textareaQ" name="q4" readonly><?php echo $question4; ?></textarea> </center> <br /><br /> <p class="marA"> <input type="radio" name="rad4" value="<?php echo $opt1; ?>" /> <label class="lbl"><?php echo $opt1 ?></label><br /> <input type="radio" name="rad4" value="<?php echo $opt2; ?>" /> <label class="lbl"><?php echo $opt2 ?></label><br /> <input type="radio" name="rad4" value="<?php echo $opt3; ?>" /> <label class="lbl"><?php echo $opt3 ?></label><br /> </p> </div> <div class="lr"> <center> <br /><br /><br /><br /> <a class="nxt" href="#q3"><label title="Proceed to 3rd Question">Back</label></a> | <a class="nxt" href="#q5"><label title="Proceed to 5th Question">Next</label></a> </center> </div> <br /><br /><br /> <center><hr width="90%" /></center><br /> <?php } ?> <br /><br /> <?php $q = mysql_query("SELECT * FROM histact1 WHERE question != '$question1' AND question != '$question2' AND question != '$question3' AND question != '$question4' ORDER BY RAND() LIMIT 1"); while ($r1 = mysql_fetch_array($q)){ $id = $r1[0]; $question5 = $r1[1]; $opt1 = $r1[3]; $opt2 = $r1[4]; $opt3 = $r1[5]; ?> <div class="Qset" id="q5"><br /><br /> <label class="items">5th Question :</label> <br /> <center> <textarea class="textareaQ" name="q5" readonly><?php echo $question5; ?></textarea> </center> <br /><br /> <p class="marA"> <input type="radio" name="rad5" value="<?php echo $opt1; ?>" /> <label class="lbl"><?php echo $opt1 ?></label><br /> <input type="radio" name="rad5" value="<?php echo $opt2; ?>" /> <label class="lbl"><?php echo $opt2 ?></label><br /> <input type="radio" name="rad5" value="<?php echo $opt3; ?>" /> <label class="lbl"><?php echo $opt3 ?></label><br /> </p> </div> <div class="lr"> <center> <br /><br /><br /><br /> <a class="nxt" href="#q4"><label title="Proceed to 4th Question">Back</label></a> | <input type="submit" title="Submit Answers" name="submit" class="submit" value=" Submit " onclick="return confirm('Are you sure you want to submit your answers?\nYou can review your answer by click the Back link')" /> </center> </div> <br /><br /><br /> <center><hr width="90%" /></center><br /> <?php } ?> </form> Edited by mac_gyver, 09 October 2014 - 10:51 AM. code in code tags please Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in C:\xampp\test.php on line 58 line 58 is the where the while loop starts.. what have i done wrong? Code: [Select] $query2 = mysql_query("SELECT student.SID, course.CID FROM student, course WHERE student.SID = `student-course.SID` AND course.CID = `student-course.CID` AND GRADE BETWEEN $beginning AND $grade",$this->connect); while($row = mysql_fetch_assoc($query2)) { $sid = $row['student.SID']; $cid = $row['course.CID']; echo "$sid-$cid"; } we did an exercise in IT class it was about how to inject php code in css code we took a template as an example to work on. i injected php code in the page "services.php"as instructed but it didn't work and i keep getting this error : Please help, This code is giving me the warning stated in the above given Subject line. And combo box is also not populating. Code: [Select] function populatecombo() { $dropdown = ""; $sqlcmb = "select wardno from wards"; mysql_query($sqlcmb) or die(mysql_error('Unable to query the table')); while($row = mysql_fetch_assoc($sqlcmb)) { $dropdown .= "\r\n<option value='{$row['wardno']}>'{$row['wardno']}</option>"; } echo $dropdown; } I am trying to install a comments box, im new to php and mysql so havent been able to work this out for myself following other threads, hope someone can shed some light on the problem. The posts ive entered arent being returned to the page essentially and im getting the error: Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in commentbox.php on line 42. This is the code from the entire page. Code: [Select] <?php require('commentconnect.php'); $name=@$_POST['name']; $comment=@$_POST['comment']; $submit=@$_POST['submit']; if($submit) { if($name&&$comment) { $insert=mysql_query("INSERT INTO commenttable (name,comment) VALUES ('$name','$comment')"); /*header("Location: index.php");*/ echo "<script>document.location.href='index.php'</script>"; echo "<script>'Content-type: application/octet-stream'</script>"; } else { echo "Please fill out the fields"; } } ?> <div id="commentdiv"> <div id="commentinput"> <form action="index.php" method="POST"> <table> <tr><td>Name: </td><td><input type="text" name="name" /></td></tr> <tr><td colspan="2">Comment: </td></tr> <tr><td colspan="2"><textarea name="comment"></textarea></td></tr> <tr><td colspan="2"><input type="submit" name="submit" value="Comment" /></td></tr> </table> </form> </div> <div id="commentarea"> <?php $getquery=mysql_query("SELECT * FROM commenttable ORDER BY id DESC"); while($rows=mysql_fetch_array($getquery)) { $id=$rows['id']; $name=$rows['name']; $comment=$rows['comment']; $dellink="<a href=\"delete.php?id=" . $id . "\"> Delete </a>"; echo $name . '' . '<br />' . $comment . '<br />' . '<hr/>'; } ?> </div> </div> Any help is greatly appreciated! 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. This has been really annoying me for 2 hours now . I know its something silly Database Structure QuestionID int Question VarChar HelpDocument VarChar (Link) Posting Code: <!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> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js"></script> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.5.3/jquery-ui.min.js"></script> <script type="text/javascript" src="jquery.simpledialog/jquery.simpledialog.0.1.js"></script> <link rel="stylesheet" type="text/css" href="style.css" /> <link rel="stylesheet" href="ui.datepicker.css" type="text/css" media="screen" /> <link rel="stylesheet" href="jquery.simpledialog/simpledialog.css" type="text/css" media="screen" /> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/ libs/jquery/1.3.0/jquery.min.js"></script> <script type="text/javascript"> $(function() { $(".search_button").click(function() { var search_word = $("#search_box").val(); var dataString = 'search_word='+ search_word; if(search_word=='') { } else { $.ajax({ type: "GET", url: "getHelpDocuments.php", data: dataString, cache: false, beforeSend: function(html) { document.getElementById("insert_search").innerHTML = ''; $("#flash").show(); $("#searchword").show(); $(".searchword").html(search_word); $("#flash").html('<img src="ajax-loader.gif" /> Loading Results...'); }, success: function(html){ $("#insert_search").show(); $("#insert_search").append(html); $("#flash").hide(); } }); } return false; }); }); </script> <style> *{margin:0;padding:0;} ol.update { list-style:none; font-size:1.1em; margin-top:20px } ol.update li { height:70px; border-bottom:#dedede dashed 1px; text-align:left; } ol.update li:first-child { border-top:#dedede dashed 1px; height:70px; text-align:left } </style> </head> <body> <div id="AllContent"> <div id="header"> <br></br> <br></br> </div> <br></br> <div id="login"> </div> <br></br> <br></br> <br></br> <br></br> <br></br> <br></br> <br></br> <div id="RequestAccess"> <form method="get" action=""> <input type="text" name="search" id="search_box" class='search_box'/> <input type="submit" value="Search" class="search_button" /> </form> <div id="searchword"> Search results for <span class="searchword"></span></div> <div id="flash"></div> <ol id="insert_search" class="update"> </ol> </ul> </div> </div> </div> </div> </body> </html> PHP SCRIPT <?php if(isset($_GET['search_word'])) { $search_word=$_GET['search_word']; $search_word_new=mysql_escape_string($search_word); $search_word_fix=str_replace(" ","%",$search_word_new); $link = mysql_connect("localhost", "root", ""); mysql_select_db("blank", $link); $sql=mysql_query("SELECT HelpDocument FROM Questions WHERE Question LIKE '%$search_word_fix%' ORDER BY Question DESC LIMIT 20", $link); $count=mysql_num_rows($sql); if($count > 0) { while($row=mysql_fetch_array($sql)) { $msg=$row['Question']; $bold_word='<b>'.$search_word.'</b>'; $final_msg = str_ireplace($search_word, $bold_word, $msg); ?> <li><?php echo $final_msg; ?></li> <?php } } else { echo "<li>No Results</li>"; } } ?> getting this error Warning: mysql_num_rows() expects parameter 1 to be resource and it wont display the database fields after search Any help is deeply appreciated thanks Ive been having trouble. Im getting this error: Code: [Select] $select = mysql_query($query1); echo $select; $rows1 = mysqli_fetch_array($dbc, $select); I dont understand whats wrong. I have created a script to insert data into a database, but it returns this. Code: [Select] Warning: mysql_select_db() expects parameter 2 to be resource, null given in /RJFWS198/testing/elemata_project/admin/elements/create_page.php on line 51 Here is the code Code: [Select] <?PHP //Protect Against Attacks if (empty($_SESSION['E_User'])) { die("Access Denied"); } ?> <?php if (!empty($_REQUEST['title']) && (!empty($_SESSION['E_User']))) { require_once('../Connections/default.php'); if (empty($_REQUEST['password'])) { $password = "0"; }else{ $password = $_REQUEST['password']; } if (empty($_REQUEST['menu_order'])) { $mo = "0"; }else{ $mo = $_REQUEST['menu_order']; } if (empty($_REQUEST['meta_keywords'])) { $meta_keywords = "0"; }else{ $meta_keywords = $_REQUEST['meta_keywords']; } if (empty($_REQUEST['meta_desc'])) { $meta_desc = "0"; }else{ $meta_desc = $_REQUEST['meta_desc']; } if (empty($_REQUEST['meta_copyright'])) { $meta_copyright = "0"; }else{ $meta_copyright = $_REQUEST['meta_copyright']; } $author = $_SESSION['E_User']; $date = date("m.d.y"); $day = date("d"); $month = date("n"); $year = date("Y"); $time = ''.date("g").''.date("i").''.date("a").''; $ptitle = $_REQUEST['title']; $post_content = $_REQUEST['postContent']; $searchable = $_REQUEST['seachable']; $locked = $_REQUEST['privacy']; $tags = $_REQUEST['tags']; $meta_robots = $_REQUEST['robots']; mysql_select_db($database_default, $default); mysql_query("INSERT INTO posts (`time`, `year`, `month`, `day`, `date`, `author`, `title`, `content`, `searchable`, `locked`, `password`, `menu_order`, `tags`, `meta_keywords`, `meta_desc`, `meta_robots`, `meta_copyright`) VALUES ('$time', '$year', '$month', '$day', '$date', '$author', '$ptitle', '$post_content', '$searchable', '$locked', '$password', '$mo', '$tags', '$meta_keywords', '$meta_desc', '$meta_robots', '$meta_copyright')"); } ?> Hey, this is my first post here, so bear with me: I'm new to PHP, and am trying to make an online store, right now I'm just making an admin inventory management, and so I'm using PHP to link to the database. Before any of this script, I link to the database and all that, so it's not an issue of connection. My issue is I keep getting the following message: Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in "inventory_list.php" on line 38 Column count doesn't match value count at row 1 There used to be three or four other error messages, but I've been able to work out my mistakes and fix them. Here is my code, starting at Line 27: Code: [Select] <?php // Parse the form data and add inventory item to the system if (isset($_POST['product_name'])) { $product_name = mysql_real_escape_string($_POST['product_name']); $price = mysql_real_escape_string($_POST['price']); $category = mysql_real_escape_string($_POST['category']); $subcategory = mysql_real_escape_string($_POST['subcategory']); $details = mysql_real_escape_string($_POST['details']); // See if that product name is an identicle match to another in the system $sql = mysql_query("SELECT product_id FROM products WHERE product_name='$product_name' LIMIT 1"); $productMatch = mysql_num_rows($sql); // count the output amount if ($productMatch > 0){ echo 'Sorry, you tried to place a duplicate "Product Name" into the system, <a href="inventory_list.php">click here</a>'; exit(); } // Add this product into the database now $sql = mysql_query("INSERT INTO product (product_name, price, category, subcategory, date_added) VALUES('$product_name','$price','$details','$category','$subcategory',now())") or die (mysql_error()); $pid = mysql_insert_id(); // Place image in the folder $newname = "$pid.jpg"; move_uploaded_file($_FILES['fileField']['tmp_name'], "../inventory_images/$newname"); } ?> The line causing this issue is thus: Code: [Select] $productMatch = mysql_num_rows($sql); // count the output amount Does anyone know how to fix this for me? Thanks When i try and use this app on my website i get the error, Code: [Select] Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in /home/unionc/public_html/auction/scripts/updateTables.php on line 15 Code: [Select] <?php $now = time(); add_column_if_not_exist("WA_SellPrice", "seller", "VARCHAR( 255 ) NULL"); add_column_if_not_exist("WA_SellPrice", "buyer", "VARCHAR( 255 ) NULL"); add_column_if_not_exist("WA_Players", "canBuy", "INT(11) NOT NULL DEFAULT '0'"); add_column_if_not_exist("WA_Players", "canSell", "INT(11) NOT NULL DEFAULT '0'"); add_column_if_not_exist("WA_Players", "isAdmin", "INT(11) NOT NULL DEFAULT '0'"); add_column_if_not_exist("WA_Auctions", "created", "INT(11) NULL"); function add_column_if_not_exist($table, $column, $column_attr){ $exists = false; $columns = mysql_query("show columns from $table"); while($c = mysql_fetch_assoc($columns)){ if($c['Field'] == $column){ $exists = true; break; } } if(!$exists){ mysql_query("ALTER TABLE `$table` ADD `$column` $column_attr"); } } ?>Please Help! Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\websiteku\modul\laporan\laporan.php on line 48 $query2 = "SELECT count(*) as jum1 FROM transaksi WHERE nama_kategori = '$namaBidang' AND nama_bayar = Uang"; $hasil2 = mysql_query($query2); $data3 = mysql_fetch_array($hasil2); $jumGol1 = $data3['jum1'];help me guys, how i fix this problem ?? i give it up after 4 h. please help me, what i do wrong I have this code Code: [Select] $id = $_GET['esitysid']; $esitysnimi = mysql_query("SELECT * FROM varasto WHERE id = '".$id."", $yhteys); print "esitysnimi $esitysnimi"; $esitysnim = mysql_result($esitysnimi, "0", "nimi"); varasto: Code: [Select] nimi hinta maara id lippuja Esitys Nimi 1 10 14 0 5 Esitys Nimi 2 120 5 1 0 Esitys Nimi 3 950 5 2 0 and it says Code: [Select] Warning: mysql_result() expects parameter 1 to be resource, boolean given How can I fix it? Thank you for help HELP ME TO CHANGE THE ERROR <?PHP //Include connection to database include('connect.php'); //Get posted values from form $status=$_POST['status']; $date=$_POST['date']; //Strip slashes $status = stripslashes($status); $date = stripslashes($date); //Strip tags $status = strip_tags($status); $date = strip_tags($date); //Inset into database $insert_status = mysql_query(" insert into status (status) value ('$status')") or die (mysql_error()); $insert_status = mysql_query("insert into status (date) value ('$date')") or die (mysql_error()); while($row = mysql_fetch_array($insert_status)) { (ERROR IS IN THIS LINE) $status=$row['status']; $date=$row['date']; } //Line break after every 80 $status = wordwrap($status, 80, "\n", true); //Line breaks $status=nl2br($status); //Display status from data base echo '<div class="load_status"> <div class="status_img"><img src="blankSilhouette.png" /></div> <div class="status_text"><a href="#" class="blue">Anonimo</a><p class="text">'.$status.'</p> <div class="date">'.$date.' · <a href="#" class="light_blue">Like</a> · <a href="#" class="light_blue">Comment</a></div> </div> <div class="clear"></div> </div>'; ?> Hi, I'm fairly new to PHP and have run into this problem, I have tried looking through some other peoples solutions to this but don't quite understand them! I have set up a simple news post on a website which works fine, however when I go to edit a post and try to submit it again it comes up with this error: Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in /Users/mdfcows/Sites/atelier/editnews.php on line 61 It still works, i.e. posts it, however I don't quite know what this means, and now I am trying to set it up so that another page can be edited and all I am getting is the same error on the page without any of the other info or PHP coming up! this is the PHP I am using, with the line "while ($row = mysql_fetch_assoc ($result)) {" being line number 61 Code: [Select] <?php require_once('config.php'); $con = mysql_connect(DB_HOST,DB_USER,DB_PASSWORD); if (!$con){ die('Failed to connect to server' . mysql_error()); } mysql_select_db(DB_DATABASE); $ide = $_POST[idf]; $query = "SELECT image,id,title,text FROM news WHERE id = $ide"; $result = mysql_query($query); while ($row = mysql_fetch_assoc ($result)) { $title = htmlentities ($row['title']); $news = nl2br (strip_tags ($row ['text'], '<a><b><i><u>')); $image = $row['image']; echo "<form class ='addform' action='editnews.php' enctype='multipart/form-data' method='post'>"; echo "<input type='hidden' name='ida' value='$ide' />"; echo "<p>Title:<br /><input class='titlefield' type='text' name='title' value='$title' /></p><br />"; echo "<p>News Post:<br /> <textarea name='news' rows='12' cols='50'>$news</textarea></p><br />"; echo "<p>If you uploaded an image with your post you will need to upload it again<br /><input type='hidden' name='MAX_FILE_SIZE' value='20000000' /> <input name='userfile' type='file' value='$image' id='userfile' /></p><br />"; echo "<p><input name='submit' type='submit' value='Submit' /></p>"; echo "</form>"; } if ($_POST['submit']) { mysql_select_db(DB_DATABASE); $upid = $_POST[ida]; $uptitle = $_POST[title]; $upnews = $_POST[news]; $upimage = $_FILES['userfile']['name']; $sql = "UPDATE news SET title = '$uptitle', text = '$upnews', image = '$upimage' WHERE id = '$upid'"; mysql_query($sql); if ($_POST['submit']) { echo "<p class='admintext'>Your post has been Edited - <a href='index.php'>View Latest News Page</a></p><br />"; $name = $_FILES['userfile']['name']; $type = $_FILES['userfile']['type']; $size = $_FILES['userfile']['size']; $tmpname = $_FILES['userfile']['tmp_name']; $ext = substr($name, strrpos($name, '.')); if (strstr($type, "image")) { move_uploaded_file($tmpname, "images/".$name); } } } ?> Any help would be much appreciated! Thank you Martin Full error: Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\MyWebsite\poll\functions.php on line 28 Been working all day to set up some stuff in my website. Now currently working on the poll. Been stuck on this error and I don't know what to do. That's the function that throws this: Any help would be appreciated. Code: [Select] function getPoll($pollID){ $query = "SELECT * FROM polls LEFT JOIN pollAnswers ON polls.pollID = pollAnswers.pollID WHERE polls.pollID = " . $pollID . " ORDER By pollAnswerListing ASC"; $result = mysql_query($query); //echo $query;jquery $pollStartHtml = ''; $pollAnswersHtml = ''; while($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $pollQuestion = $row['pollQuestion']; $pollAnswerID = $row['pollAnswerID']; $pollAnswerValue = $row['pollAnswerValue']; if ($pollStartHtml == '') { $pollStartHtml = '<div id="pollWrap"><form name="pollForm" method="post" action="poll/functions.php?action=vote"><h3>' . $pollQuestion .'</h3><ul>'; $pollEndHtml = '</ul><input type="submit" name="pollSubmit" id="pollSubmit" value="Vote" /> <span id="pollMessage"></span></form><>'; } $pollAnswersHtml = $pollAnswersHtml . '<li><input name="pollAnswerID" id="pollRadioButton' . $pollAnswerID . '" type="radio" value="' . $pollAnswerID . '" /> ' . $pollAnswerValue .'<span id="pollAnswer' . $pollAnswerID . '"></span></li>'; $pollAnswersHtml = $pollAnswersHtml . '<li class="pollChart pollChart' . $pollAnswerID . '"></li>'; } echo $pollStartHtml . $pollAnswersHtml . $pollEndHtml; } don't know what to do next with this error popping up,,,any help? <?php //set up the variables $loguser = $_POST['loguser']; $logpass = md5($_POST['logpass']); $login = $_get['login']; //connect with the server and the database mysql_connect("localhost","root","") or die("Can't connect with the Server!"); mysql_select_db("comp3project") or die("Can't connect with the database!"); if($login="yes") { $get = mysql_query("SELECT count(cid) FROM customer_data WHERE username = '$loguser' and password = '$logpass'"); $result = mysql_result($get,0); if($result!=1){print "Login Failed!";} else {print "Login Successful!";} } ?> I can't find what's wrong with the code... <?php $Sql = "select team1, team2, t1outcome, t2outcome, winner from coupons where user='$User'"; $Result = mysql_query($Sql, $Link); print "<table cellpadding=0 cellspacing=0 border=0>"; print "<tr>"; print "<td align=left valign=top> </td>"; print "<td align=left valign=top> </td>"; print "</tr>"; while($Row = mysql_fetch_array($Result)){ if($Row[team1] == $Row[winner]){ print "<tr>"; print "<td align=left valign=top> </td>"; print "<td align=left valign=top><bold>$Row[team1]</bold> - $Row[team2] $Row[t1outcome]-$Row[t2outcome]</td>"; print "</tr>"; } else { print "<tr>"; print "<td align=left valign=top> </td>"; print "<td align=left valign=top>$Row[team1] - $Row[team2] $Row[t1outcome]-$Row[t2outcome]</td>"; print "</tr>"; } } print "</table>"; mysql_close($Link); ?> |