PHP - Problem With Mysqli_result
Hello, I have a serious problem that I need to fix for a client and I have no idea how to fix it. I have a client that is running vBulletin 4.2.2 P1 and since a server upgrade we have gotten this error when they to access a hack that we have installed called Easy Forms. I would not ask here except there is little to no help on vbulletin.org. The coder who created this hack is in the wind and has not been on the site since October 4, has a full PM box and is not answering messages and others on the site are trying to help but I'm not a php coder so i have no idea where to start to fix it even with their help. Here is the error we get:
Fatal error: Cannot use object of type mysqli_result as array in /home/public_html/forum/forms.php on line 1242
The form.php is the file that pertains to the hack we have installed. This hack was isntalled BEFORE the host went and screwed around with stuff and it worked fine before hand.
The code around that line and including that line is:
$formbits = $vbulletin->db->query_read("SELECT * FROM " . TABLE_PREFIX . "formbits WHERE fid = $fid ORDER BY displayorder ASC"); while($formbit = $vbulletin->db->fetch_array($formbits)) { ($hook = vBulletinHook::fetch_hook('easy_forms_view_question_start')) ? eval($hook) : false; if ($formbit[guestonly] && $vbulletin->userinfo[userid]) { continue; } $formbit['value'] = $q[$formbit[id]]; $bbcode_parser = new vB_BbCodeParser($vbulletin, fetch_tag_list()); $formbit[question] = $bbcode_parser->parse($formbit[question]); $bbcode_parser = new vB_BbCodeParser($vbulletin, fetch_tag_list()); $formbit[description] = $bbcode_parser->parse($formbit[description]); $formbit['qlc'] = trim($formbit['question']); $formbit['qlc'] = substr($formbit['qlc'], -1); if ($formbit['qlc'] != "?" && $formbit['qlc'] != ":" && $formbit['type'] != 7) { $formbit['question'] = $formbit['question'] . ":"; } if ($formbit['compulsory'] == 1) { $formbit['question'] = $formbit['question'] . $vbphrase[form_compulsory_symbol]; } $question++; $formbit[inputerror] = $inputerror[$formbit[id]]; if ($formbit['type'] == 1) {Line 1242 is $formbit['value'] = $q[$formbit[id]];. If you need more code than that please let me know. I think it has to do with the questions being added. I have uninstalled this hack and reinstalled it as a fresh install twice and still get the same errors. When I reinstalled the second time instead of importing the client's backed up form I created a fresh test one and when I clicked on "View Form" before adding any questions to the form it worked just fine. But after I added questions I click on the "View Form" link and get that error again, so it is somehow related to the questions. Some info about what we are running on the site: vBulletin 4.2.2 P1 Suite PHP 5.4.33 MySQL 5.5.37 i have been informed that the code would now need arrays but that is about all they have said which is great help if I were a programmer. I'm able to edit the code (With direction) with no problem, but I do not hand code it or know where everything should or should not be. Any help would be great on this matter. Thanks. Edited by LenKaiser, 24 October 2014 - 07:39 PM. Similar TutorialsHey Guys, So I have a zip code database with 40,000 some entries... and I am reading a query and returning it and need it to store it in array similar to this snippet of code . $cities = array( array('city'=>'New York', 'state'=>'NY', 'zip'=>'10001'), array('city'=>'Los Angeles', 'state'=>'CA', 'zip'=>'90001'), array('city'=>'Chicago', 'state'=>'IL', 'zip'=>'60601'), array('city'=>'Houston', 'state'=>'TX', 'zip'=>'77001'), array('city'=>'Phoenix', 'state'=>'AZ', 'zip'=>'85001'), array('city'=>'Philadelphia', 'state'=>'PA', 'zip'=>'19019'), array('city'=>'San Antonio', 'state'=>'TX', 'zip'=>'78201'), array('city'=>'Dallas', 'state'=>'TX', 'zip'=>'75201'), array('city'=>'San Diego', 'state'=>'CA', 'zip'=>'92101'), array('city'=>'San Jose', 'state'=>'CA', 'zip'=>'95101'), array('city'=>'Detroit', 'state'=>'MI', 'zip'=>'48201'), array('city'=>'San Francisco', 'state'=>'CA', 'zip'=>'94101'), array('city'=>'Jacksonville', 'state'=>'FL', 'zip'=>'32099'), array('city'=>'Indianapolis', 'state'=>'IN', 'zip'=>'46201'), array('city'=>'Austin', 'state'=>'TX', 'zip'=>'73301'), array('city'=>'Columbus', 'state'=>'OH', 'zip'=>'43085'), array('city'=>'Fort Worth', 'state'=>'TX', 'zip'=>'76101'), array('city'=>'Charlotte', 'state'=>'NC', 'zip'=>'28201'), array('city'=>'Memphis', 'state'=>'TN', 'zip'=>'37501'), array('city'=>'Baltimore', 'state'=>'MD', 'zip'=>'21201'), ); Here is the code I currently have... But it is not being stored into an array, it is just a mysqli_result object with the correct amount of num_rows, and fields. $cities = $zip->getAllZipCityState(); function getAllZipCityState() { // Get ALL Zip / City / State $query = 'SELECT ' . $this->dbZip . ', ' . $this->dbCity . ', ' . $this->dbState . ' '; $query.= 'FROM ' . $this->dbTable . ' '; //$qry = mysql_query($query,$this->db); $qry = $this->db->query($query); if(!$qry){ echo "MySql Error #".mysqli_errno($this->db).': '.mysqli_error($this->db).'<br>'; die; } //return mysqli_fetch_array($qry); return $qry; } Thanks! Hi guys, I received an error, could anyone explain this current error? Thanks Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in D:\inetpub\vhosts\championtutor.com\httpdocs\questionnaire.php on line 32 Hi all
i am using the code below, but am getting the error
Object of class mysqli_result could not be converted to int
<?php $sql="SELECT lng,lng_prefix FROM tbl_languages where active = 1"; $result=mysqli_query($dbConn, $sql)or die(mysqli_error($dbConn)); //problem line if(mysqli_num_rows($result==1)){ ?>The code continues with what I want to happen based on the result. What does the error mean and how do I fix it? The following is an extract of PHP code I have interacting with a MySQL database and I keep getting the "object of class mysqli_result could not be converted to string" error on the line of code inside my loop. This is my code.
#This is just storing a single integer, a moduleID
$sqlmodID = mysqli_query($con,"select moduleID from module_details WHERE moduleName = '$moduleName' AND lecturerID = '$lecturerID'"); #This is a query to get relevant idNumbers $sqlstudent = "select idNum from user_info WHERE courseCode = '$courseCode'";
#Running the previous statement $result = mysqli_query($con, $sqlstudent);
#Storing the statements results in an array $row = mysqli_fetch_array($result);
#I'm not sure if this line is necessary but it converts the array values into a string (I'm storing the ID's as strings as they contain numbers and letters) $studentArray = array_map('strval', $row);
#The error flashes on my condition of this loop. I'm trying to take each element of my array, and enter it to my table, assigning each variable the same ModuleID.
for($i=0; $i < count($studentArray); $i++){
Any help would be much appreciated. I hope I've explained my code sufficiently. Hi
I am a student who is fairly new to PHP and MySQL. I have been working on creating a registration page for a website and I'm getting the following warnings when I've tested the page:
Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in /home/ed12e2w/public_html/COMM2735/dynamic_website/registration.php on line 74 Warning: mysqli_free_result() expects parameter 1 to be mysqli_result, boolean given in /home/ed12e2w/public_html/COMM2735/dynamic_website/registration.php on line 80 I think that my query has failed but I'm not completely sure on what to change in order to solve this. Here is the section of code I'm having problems with: Attached Files register.php 733bytes 4 downloads I have searched the internet about this and found hundreds have asked the question and not once was it answered in a meaningful way--or maybe I'm just dense. Would somebody please tell me what is the problem he Simple, simple form:
<html>
<form action="send_post.php" method="post">
</body> =========== Simple, simple PHP script:
<?php
if (mysqli_num_rows($result) > 0) { But most importantly, how should it be written so that it returns the desired results? I have checked the query from the CMD line, it returns multiple entries. Really, I have reached FRUSTRATION OVERLOAD! Edited April 12, 2020 by eljaydeeHi all, I have received a warning message, which it still puzzles me. I suspect it might be my inner join command, which I have coded it wrongly? Line 37 refers to this line - if (mysqli_num_rows($data) == 1) { Do you guys have any idea? Thanks Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in D:\inetpub\vhosts\123.com\http\viewprofile.php on line 37 Code: [Select] <?php // Connect to the database $dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); $query = "SELECT tp.name, tp.nric, tp.gender, tp.race_id, r.race_name AS race" . "FROM tutor_profile AS tp " . "INNER JOIN race AS r USING (race_id) " . "WHERE tutor_id = '" . $_GET['tutor_id'] . "'"; $data = mysqli_query($dbc, $query); if (mysqli_num_rows($data) == 1) { // The user row was found so display the user data $row = mysqli_fetch_array($data); echo '<table>'; if (!empty($row['name'])) { echo '<tr><td class="label">Name:</td><td>' . $row['name'] . '</td></tr>'; } if (!empty($row['nric'])) { echo '<tr><td class="label">NRIC:</td><td>' . $row['nric'] . '</td></tr>'; } if (!empty($row['last_name'])) { echo '<tr><td class="label">Last name:</td><td>' . $row['last_name'] . '</td></tr>'; } if (!empty($row['gender'])) { echo '<tr><td class="label">Gender:</td><td>'; if ($row['gender'] == 'M') { echo 'Male'; } if ($row['gender'] == 'F') { echo 'Female'; } echo '</td></tr>'; } if (!empty($row['race'])) { echo '<tr><td class="label">Race:</td><td>' . $row['race'] . '</td></tr>'; } echo '</table>'; //End of Table echo '<p>Would you like to <a href="editprofile.php?tutor_id=' . $_GET['tutor_id'] . '">edit your } // End of check for a single row of user results else { echo '<p class="error">There was a problem accessing your profile.</p>'; } mysqli_close($dbc); ?> Someone help me in this problem please?? Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in line 8 $rec= mysqli_query ($db, "SELECT FROM joborder WHERE id=$id"); $record = mysqli_fetch_array ($rec); // line 8 $fnames= $record ['fnames'] ; Edited March 8 by kei
<!DOCTYPE html>
{ Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in /home/myritebook/public_html/footer.php on line 13 I am trying to fix the above error. Please Help. code is given below:
<?php
if ($conn) {
try{
catch(Exception $e){ Hi Guys.
Doing an assignment for uni, and stuck on an error. Ill attach some files to show the problem and any help very much appreciated.
Error and the screen it comes on
Code
<?php $select = mysqli_query($con, "SELECT * FROM categories");
while ($row = mysqli_fetch_assoc($select)) { }
function dispsubcategories($parent_id) {
}
function getnumtopics($cat_id, $subcat_id) {
and the structure of the database
Edited March 28, 2020 by Ben555 I have a table with a list of users and an edit button and delete button. When the edit button is pressed on a site it passes the user_id as p_id to the page that catches it and displays the data. The problem is when I click on the "update user" button, I get the following error:
Warning: Undefined variable $the_user_id in C:\xampp\htdocs\3-19-21(2) - SafetySite\admin\edit_user.php on line 10 The weird thing is I had another update user page with a table I created that ran the query to update the table in the database just fine. But as I created it, it didn't look all that great so I recreated the page and used a bootstrap table because of the much cleaner look. Both pages have the exact same PHP code, the only difference is the bootstrap table I added in. So I'm really at a loss with this. Other than the table and PHP code, there is a script at the bottom of the page for the table itself to allow for searching within the table, i'll include that as well. The PHP code is as follows:
<?php //THE "p_id" IS BROUGHT OVER FROM THE EDIT BUTTON ON VIEW_ALL_USERS if (isset($_GET['p_id'])) { $the_user_id = $_GET['p_id']; } // QUERY TO PULL THE SITE INFORMATION FROM THE p_id THAT WAS PULLED OVER $query = "SELECT * FROM users WHERE user_id = $the_user_id "; $select_user = mysqli_query($connection,$query); //SET VALUES FROM ARRAY TO VARIABLES while($row = mysqli_fetch_assoc($select_user)) { $user_id = $row['user_id']; $user_firstname = $row['user_firstname']; $user_lastname = $row['user_lastname']; $username = $row['username']; $user_email = $row['user_email']; $user_phone = $row['user_phone']; //$user_image = $row['user_image']; $user_title_id = $row['user_title_id']; $user_role_id = $row['user_role_id']; } THE UPDATE QUERY CODE....................................................................................................................
<?php if(isset($_POST['update_user'])) { $user_id = $_POST['user_id']; $user_firstname = $_POST['user_firstname']; $user_lastname = $_POST['user_lastname']; $username = $_POST['username']; $user_email = $_POST['user_email']; $user_phone = $_POST['user_phone']; //$user_image = $_POST['user_image']; $user_title_id = $_POST['user_title_id']; $user_role_id = $_POST['user_role_id'];
$query = "UPDATE users SET "; $query .= "user_id = '{$user_id}', "; $query .= "user_firstname = '{$user_firstname}', "; $query .= "user_lastname = '{$user_lastname}', "; $query .= "username = '{$username}', "; $query .= "user_email = '{$user_email}', "; $query .= "user_phone = '{$user_phone}', "; //$query .= "user_image = '{$user_image}', "; $query .= "user_title_id = '{$user_title_id}', "; $query .= "user_role_id = '{$user_role_id}' "; $query .= "WHERE user_id = '{$the_user_id}' "; $update_user = mysqli_query($connection,$query); if(! $update_user) { die("QUERY FAILED" . mysqli_error($connection)); } } ?> THE "UPDATE USER" BUTTON THE USER CLICKS ON TO UPDATE....................................................................................................................
<div class="col-1"> <button class="btn btn-primary" type="submit" name="update_user">Update User</button> </div>
Any Help is Greatly Appreciated! Edited March 23 by ZsereneGuys thanks for helping me solve the problem i had but now i have another problem and i am lost. i have included the code below for you to have overview.
This is the code:
<table style="width:100%; margin-left:auto; margin-right:auto"> I am trying to use the following code snippet to return values from a database with a "," after each value apart form the last one. At the moment for testing I have 2 rows with values 1 and 3 $totalRows_Recordset3 equals 2 (I echoed this to check) $i=1; while($row_Recordset3 = mysql_fetch_assoc($Recordset3)) { if($i < $totalRows_Recordset3) { $str = $str.$row_Recordset3['reading'].","; $i=$i+1; } else { $str = $str.$row_Recordset3['reading']; $i=$i+1; } } I get the number 3 which is the last value in the database, but I can't see why I don't get "1,3" I am sure it is something simple but it just escapes me. Thanks in advance for any help Gordon Hi everyone. I have written a PHP script gets data from a MySQL database and attempts to convert it to an RSS feed. The problem I am having is that when I preview the feed the "article_type", "article_author", "article_author2" and "article_company" information is not showing up in the feed. Have I coded this wrong? Thanks for any help. while($rss_array = mysql_fetch_array($rss_rs)) { $xml .= "<item><title><![CDATA[" . $rss_array['article_title'] . "]]></title> <link><![CDATA[index.php?skip=true&article=" . $rss_array['article_number'] . "]]></link><guid><![CDATA[index.php?skip=true&article=" . $rss_array['article_number'] . "]]></guid><description><![CDATA[" . str_replace("'", "", $rss_array['article_description']) . "]]></description> <article_type>" . $rss_array['article_type'] . "</article_type> <article_author>" . $rss_array['article_author'] . "</article_author> <article_author2>" . $rss_array['article_author2'] . "</article_author2> <article_company>" . $rss_array['article_company'] . "</article_company> </item>"; } Hi, i use mysql_real_escape_string() function when insert in db, but when echo i use htmlentities($var, ENT_QUOTES, "UTF-8") Now problem is '\ in that text. In db it write text with single quote with \, example That\'s wrong, and when echo it show just the same like in db.. How can i fix this ? i have written a script using touch() function for creating new pages.. but the url's appear are not search engine frendly i want the urls to appear like this everyspace filled with - oder than a space because the space makes the url display as http://localhost/gl/uploads/movies/2010/08/The%20Hangman%202010%20Hindi%20Movie%20Watch%20Online/The%20Hangman%202010%20Hindi%20Movie%20Watch%20Online.php I want it to appear this way http://www.onlinewatchmovies.net/hindi/vroom-2010-hindi-movie-watch-online.html any suggestion how can i do this? Code: [Select] <?php require('config.php'); $sql = "SELECT m.Title as title , f.Reg_URL as reg FROM website_main as m JOIN website_front as f LIMIT 0,01 "; $result = @mysql_query($sql) or die(mysql_error()); echo "<table border='3'>"; echo "<font size='9'><tr> <th><FONT COLOR=red><center>Title</center></font></th> <th><FONT COLOR=red>reg</th> </tr></font>"; // keeps getting the next row until there are no more to get while($row = mysql_fetch_array( $result )) { // Print out the contents of each row into a table $reg = $row['reg']; echo "<tr><td bgcolor=''><center>"; echo $row['title']; echo "</td><td bgcolor=''><center>"; echo '.$reg.'; echo "</td></tr>"; } ?> I got a problem i try to use an attribute for $reg but only appears as .$reg. on website anyone know why? Parts i have problems with are $reg = $row['reg']; and echo '.$reg.';. thank you Hi there, I have a map of America made in flash, where you click on a state and the page should display the SQL database information for that state in the HTML table - but instead all it shows is the first entry of the database regardless of which state you click and it doesn't display the 2 radio buttons. My code is as follows Flash Actionscript 3 (just showing one state) Code: [Select] function waClick(event:MouseEvent):void { var waURL:URLRequest = new URLRequest("restaurants.php?state=Washington"); navigateToURL(waURL, "_self"); } wa_btn.addEventListener(MouseEvent.CLICK, waClick); PHP code Code: [Select] <?php include("mvfconnect.php"); $theChoice = $_GET['state']; $query = "SELECT * FROM restaurants WHERE" .$theChoice; $result = @ mysql_query($query); if (!$result) { $message="Unfortunately we are having problems with this page, we promise to have it fixed as soon as possible"; die($message); } $num = mysql_num_fields($result); $i=0; while ($row = mysql_fetch_array($result, MYSQL_ASSOC)){ $show1=substr($row['state'],0,50)."..."; $show2=substr($row['city'],0,50)."..."; $show3=substr($row['rname'],0,50)."..."; $show4=substr($row['address'],0,50)."..."; $show5=substr($row['pnum'],0,50)."..."; $show6=substr($row['web'],0,50)."..."; $show7=substr($row['dishes'],0,50)."..."; $show8=substr($row['dish_details'],0,50)."..."; $show9=substr($row['challenges'],0,50)."..."; $show10=substr($row['challenge_details'],0,50)."..."; $show11=substr($row['youtube'],0,50)."..."; $show12=substr($row['images'],0,50)."..."; echo "<tr>". "<td>".$row['city']."</td>". "<td>".$row['rname']."</td>". "<td>".$row['address']."</td>". "<td>".$row['pnum']."</td>". "<td>".$row['web']."</td>". "<td>".$row['dishes']."</td>". "<td>".$row['challenges']."</td>". "<td id='state".$i."' style='display:none'>".$row['state']."</td>". "<td id='city".$i."' style='display:none'>".$row['city']."</td>". "<td id='rname".$i."' style='display:none'>".$row['rname']."</td>". "<td id='address".$i."' style='display:none'>".$row['address']."</td>". "<td id='pnum".$i."' style='display:none'>".$row['pnum']."</td>". "<td id='web".$i."' style='display:none'>".$row['web']."</td>". "<td id='dishes".$i."' style='display:none'>".$row['dishes']."</td>". "<td id='dish_details".$i."' style='display:none'>".$row['dish_details']."</td>". "<td id='challenges".$i."' style='display:none'>".$row['challenges']."</td>". "<td id='challenge_details".$i."' style='display:none'>".$row['challenge_details']."</td>". "<td id='youtube".$i."' style='display:none'>".$row['youtube']."</td>". "<td id='images".$i."' style='display:none'>".$row['images']."</td>". "<td><input type='radio' name='vid' id='vid".$i."' onclick='openVideo(".$i.")' /></td>". "<td><input type='radio' name='pic' id='pic".$i."' onclick='openImage(".$i.")' /></td>". "<td class='last'style='display:none'>".$show1." ".$show2." ".$show3." ".$show4." ".$show5." ".$show6." ".$show7." ".$show8." ".$show9." ".$show10."</td>". "</tr>"; $i++; } ?> I have used this code before and it has worked fine, can someone please help me out! |