PHP - Mysql_num_rows() Expects Parameter 1 To Be Resource, Boolean Given
Hi guys,
I'm new to forums so hopefully someone can help me. I keep getting the following error: Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\wamp\www\Blog2\checklogin.php on line 27 My code is: Code: [Select] // Define $blog_user_name and $blog_user_password $blog_user_name=$_POST['blog_user_name']; $blog_user_password=$_POST['blog_user_password']; // To protect MySQL injection (more detail about MySQL injection) $blog_user_name = stripslashes($blog_user_name); $blog_user_password = stripslashes($blog_user_password); $blog_user_name = mysql_real_escape_string($blog_user_name); $blog_user_password = mysql_real_escape_string($blog_user_password); $sql="SELECT * FROM $tbl_name WHERE username='$blog_user_name' and password='$blog_user_password'"; $result=mysql_query($sql); // Mysql_num_row is counting table row $count=mysql_num_rows($result); //THIS IS LINE 27 // If result matched $blog_user_name and $blog_user_password, table row must be 1 row if($count==1){ // Register $blog_user_name, $blog_user_password and redirect to file "index.php" session_register("blog_user_name"); session_register("blog_user_password"); header("location:index.php"); } else { echo "Wrong Username or Password"; } ob_end_flush(); Please can someone help I have know idea what the problem could be. Thanks. Similar TutorialsThe 2 errors I am getting a Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in C:\wamp\www\searchstock2.php on line 36 Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\wamp\www\searchstock2.php on line 38 I am trying to search a table and return results, all fields are VARCHAR except ID (integer), here is part of my code; $link = mysql_connect("localhxxxxx","xxx",""); //(host, username, password) mysql_select_db("wadkin", $link) or die("Unable to select database"); //select which database we're using // Build SQL Query $query = "select * from stocklist where Stock Number like \'%$trimmed%\'OR Name like \'%$trimmed%\' OR Category like \'%$trimmed%\'"; if ($numresults=mysql_query($query)); $row = mysql_fetch_assoc($numresults); if ($row['COUNT(*)'] == 0); $numrows=mysql_num_rows($numresults); if ($numrows == 0) { echo "<h4>Results</h4>"; echo "<p>Sorry, your search: "" . $trimmed . "" returned zero results</p>"; } // Determine if s has been passed to script, if not use 0 if (empty($s)) { $s=0; } // get results $query .= " limit $s,$limit"; $result = mysql_query($query) or die("Couldn't execute query"); // display what the person searched for echo "<p>You searched for: "" . $var . ""</p>"; // begin to show results set echo "Results"; $count = 1 + $s ; // display the results returned while ($row= mysql_fetch_array($result)) { $title = $row["Name"]; echo "$count.) $title" ; $count++ ; } $row = mysql_fetch_assoc($numresults); = line 36 $numrows=mysql_num_rows($numresults); = line 38 i am try to make a name, address search system into my website from my database. but i got this msg [Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\xampplite\htdocs\3\searchresult.php on line 54] my full php code i.e. searchresult.php is under...... what i have mistake..... searchresult.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=iso-8859-1" /> <title>Untitled Document</title> </head> <body> <?php // TAKE THE INFORMATION FROM FORM. $search = $_GET['search']; // IF THERE IS NOT A KEYWORD GIVE A MISTAKE. if (!$search) echo "You didn't enter a keyword"; else { echo "<td>You searched for: <strong>$search </strong></td>"; mysql_connect('localhost','root',''); mysql_select_db('search'); $id=@$_GET['id']; //QUERY IS THE CODE WHICH WILL MAKE THE SEARCH IN YOUR DATABASE. //I WROTE AN EXPLANATION ABOUT IT AFTER THE CODE. $sql = "CREATE TABLE searchform \n" ."(\n" ."ID int NOT NULL AUTO_INCREMENT ,\n" ."FirstName varchar( 255 ) NOT NULL ,\n" ."LastName varchar( 255 ) NOT NULL ,\n" ."Email varchar( 255 ) NOT NULL ,\n" ."PhoneNumber varchar( 255 ) NOT NULL ,\n" ."PRIMARY KEY ( ID ) )";; $result1 = MySQL_query($query); if(!$result1) { echo MySQL_error()."<br>$query<br>"; } if(MySQL_num_rows($result1) > 5) { echo "<table width='750' align='center' border='0' cellspacing='0' cellpadding='0'>"; while($result2 = MySQL_fetch_array($result1)) { //A short description from category. $description = $result2['category']; $searchPosition = strpos($description, $search); $shortDescription = substr($description, $searchPosition, 150); // I added a link to results which will send the user to your display page. echo '<tr><td><p><strong><a href="displayresults.php?id='.$result2['id'].'">'.$result2['title'].'</strong></p></td></tr>'; echo "<tr><td>$shortDescription ...</td></tr>"; echo "<td>{$result2['name']} {$result2['surname']}</td><tr/>"; } echo "</table>"; }else { echo "No Results were found in this category.<br>"; }echo "<br>"; } ?> </body> </html> and searchform.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=iso-8859-1" /> <title>Untitled Document</title> </head> <body> <form action="searchresult.php" method="get"> <div align="center"> <p> <input name="search" type="text" size="60"/> <input name="submit" type="submit" value="Search" /> </p> </div> </form> </body> </html> i give it up after 4 h. please help me, what i do wrong I have tired to search this up but get nothing back.. :@ This error is on line 18 on line 18 is Code: [Select] if (mysql_num_rows($result) == 1) { Quote Notice: Undefined variable: result in C:\xampp\htdocs\Exam_Online\Staff_login\Staff_login_process.php on line 18 Warning: mysql_num_rows() expects parameter 1 to be resource, null given in C:\xampp\htdocs\Exam_Online\Staff_login\Staff_login_process.php on line 18 Wrong Username or Password This is the error message. Code: [Select] if (mysql_num_rows($result) == 1) { // Set username session variable $_SESSION['ID'] = $_POST['ID']; header("location:Staff_Menu.php"); } else { echo"Wrong Username or Password"; } Hi I'm having a bit of bother with my login. I created a login using this tutorial http://www.phpeasystep.com/phptu/6.html and it works perfectly. So i have attempted to change it to meet my own database. So basically i've changed the database, table names etc to meet my own. I haven't changed any other lines. When i run it i get an error message: Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\checklogin.php on line 26 The code is below: Code: [Select] <?php $host="localhost"; // Host name $username="root"; // Mysql username $password=""; // Mysql password $db_name="final year project"; // Database name $tbl_name="tbl_user"; // Table name // Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); // username and password sent from form $mem_username=$_POST['mem_username']; $mem_password=$_POST['mem_password']; // To protect MySQL injection (more detail about MySQL injection) $mem_username = stripslashes($mem_username); $mem_password = stripslashes($mem_password); $mem_username = mysql_real_escape_string($mem_username); $mem_password = mysql_real_escape_string($mem_password); $sql="SELECT * FROM $tbl_name WHERE username='$mem_username' and password='$mem_password'"; $result=mysql_query($sql); // Mysql_num_row is counting table row $count=mysql_num_rows($result); // If result matched $mem_username and $mem_password, table row must be 1 row if($count==1){ // Register $mem_username, $mem_password and redirect to file "login_success.php" session_register("mem_username"); session_register("mem_password"); header("location:login_success.php"); } else { echo "Wrong Username or Password"; } ?> Line 26 is $count=mysql_num_rows($result); I'm baffled as to why the test database worked. I tried another test database but got the same error. baffled.com Hope someone can help MOD EDIT: [code] . . . [/code] tags added. 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 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 i am having problem with this error, could you please help me Code: [Select] function cart () { foreach($_SESSION as $name => $value) { if ($value>0) { if (substr($name, 0, 5) == "cart_") { $productid = substr($name, 5, (strlen($name)-5)); $query = mysql_query("SELECT ProductID, Name, Price FROM product WHERE ProductID = '".mysql_real_escape_string((int)$productid."'")); while ($query_row = mysql_fetch_assoc($query)) { $sub = $query["Price"]*$Value; echo $query["Name"]. ' x ' .$value. ' @ '.$query["Price"]. ' = '.$sub.'<br />'; } } } else { echo "<p>Your Shopping Basket is empty</p>"; } } } 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 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; } I am getting the below error message: Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\Program Files (x86)\EasyPHP-5.3.9\www\a.php on line 78 The two issues a 1. The red text I need to somehow use the DISTINCT function as it is duplicating a person for every skill they have. 2. The blue text is causing the error above, if I remove the join it works but assigns every possible skill to the person (because skill table and resource table are not joined). I therefore need the join there but without the error. My code is below: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>Search Contacts</title> <style type="text/css" media="screen"> ul li{ list-style-type:none; } </style> </head> <p><body> <h3>Search Contacts Details</h3> <p>You may search either by first or last name</p> <form method="post" action="a.php?go" id="searchform"> <input type="text" name="name"> <input type="submit" name="submit" value="Search"> </form> <?php if(isset($_POST['submit'])){ if(isset($_GET['go'])){ if(preg_match("/^[ a-zA-Z]+/", $_POST['name'])){ $name=$_POST['name']; //connect to the database $db=mysql_connect ("127.0.0.1", "root", "") or die ('I cannot connect to the database because: ' . mysql_error()); //-select the database to use $mydb=mysql_select_db("resource matrix"); //-query the database table $sql="SELECT * FROM ((resource l inner join resource_skill ln on l.Resource_ID = ln.Resource_ID) inner join skill n on ln.Skill_ID = n.Skill_ID) WHERE First_Name LIKE '%" . $name . "%' OR Last_Name LIKE '%" . $name ."%' OR Skill_Name LIKE '%" . $name ."%'"; //-run the query against the mysql query function $result=mysql_query($sql); //-create while loop and loop through result set while($row=mysql_fetch_array($result)){ $First_Name =$row['First_Name']; $Last_Name=$row['Last_Name']; $Resource_ID=$row['Resource_ID']; //-display the result of the array echo "<ul>\n"; echo "<li>" . "<a href=\"a.php?id=$Resource_ID\">" .$First_Name . " " . $Last_Name . "</a></li>\n"; echo "</ul>"; } } else{ echo "<p>Please enter a search query</p>"; } } } //end of our letter search script if(isset($_GET['id'])){ $contactid=$_GET['id']; //connect to the database $db=mysql_connect ("127.0.0.1", "root", "") or die ('I cannot connect to the database because: ' . mysql_error()); //-select the database to use $mydb=mysql_select_db("resource matrix"); //-query the database table $sql="SELECT * FROM ((resource l inner join resource_skill ln on l.Resource_ID = ln.Resource_ID) inner join skill n on ln.Skill_ID = n.Skill_ID) WHERE Resource_ID=" . $contactid; //-run the query against the mysql query function $result=mysql_query($sql); //-create while loop and loop through result set while($row=mysql_fetch_array($result)){ $First_Name =$row['First_Name']; $Last_Name=$row['Last_Name']; $Mobile_Number=$row['Mobile_Number']; $Email_Address=$row['Email_Address']; $Level=$row['Level']; $Security_Cleared=$row['Security_Cleared']; $Contract_Type=$row['Contract_Type']; $Contract_Expiry=$row['Contract_Expiry']; $Day_Rate=$row['Day_Rate']; $Post_Code=$row['Post_Code']; $Skill_Name=$row['Skill_Name']; //-display the result of the array echo "<ul>\n"; echo "<li>" . $First_Name . " " . $Last_Name . "</li>\n"; echo "<li>" . $Mobile_Number . "</li>\n"; echo "<li>" . "<a href=mailto:" . $Email_Address . ">" . $Email_Address . "</a></li>\n"; echo "<li>" . $Level . "</li>\n"; echo "<li>" . $Security_Cleared . "</li>\n"; echo "<li>" . $Contract_Type . "</li>\n"; echo "<li>" . $Contract_Expiry . "</li>\n"; echo "<li>" . $Day_Rate . "</li>\n"; echo "<li>" . $Post_Code . "</li>\n"; echo "<li>" . $Skill_Name . "</li>\n"; echo "</ul>"; } } ?> </body> </html> 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); ?> I have that error repeated alot : here are the other errors Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given i n C:\Users\Andrew Hunt\Desktop\iFox.snap\Engines\MySQL\MySQL.php on line 14 Warning: mysql_free_result() expects parameter 1 to be resource, boolean given i n C:\Users\Andrew Hunt\Desktop\iFox.snap\Engines\MySQL\MySQL.php on line 15 Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given i n C:\Users\Andrew Hunt\Desktop\iFox.snap\Engines\MySQL\MySQL.php on line 14 Warning: mysql_free_result() expects parameter 1 to be resource, boolean given i n C:\Users\Andrew Hunt\Desktop\iFox.snap\Engines\MySQL\MySQL.php on line 15 The first 20 lines look like this : Code: [Select] final class MySQL { const ASSOC = MYSQL_ASSOC; public static function Connect($func_host, $func_user, $func_pass) { return mysql_connect($func_host, $func_user, $func_pass); } public static function Select($func_database) { return mysql_select_db($func_database); } public static function &Query($func_query) { return mysql_query($func_query); } public static function FetchArray(&$func_res, $func_type) { return mysql_fetch_array($func_res, $func_type); } public static function FreeResult(&$func_res) { return mysql_free_result($func_res); } public static function Error() { return mysql_error(); } public static function GetData($func_statement) { $func_retVal = array(); $func_res = self::Query($func_statement); while($func_line = self::FetchArray($func_res, MySQL::ASSOC)) $func_retVal[] = $func_line; MySQL::FreeResult($func_res); return $func_retVal; } public static function Insert($func_table, $func_data) { Thanks for help and the mysql info is correct.. 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! 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>'; ?> Code: [Select] <?php $limit=12; if(isset( $_GET['page'])) $page=$_GET['page']; if($page<=0) $page = 1; else {$start=0;} $sql=mysql_query('select * from tbl_gallery where status=1 AND category_name="0"'); $count=mysql_num_rows($sql); $totalcount=ceil($count/$limit); $start=($page-1)*$limit; $s=mysql_query('select * from tbl_gallery where status=1 AND category_name="0" limit $start, $limit'); while($result=mysql_fetch_array($s)){ $start++; ?> MOD EDIT: code tags added. |