The occurrence of mysql_num_rows is prompting a server-wide malfunction

I am trying to determine if a record exists:

$query = "SELECT * FROM `collegeInfo` WHERE `name` = '$name' ";
$existed = mysqli_query($con, $query);
echo mysql_num_rows($existed);

The third line is causing an error:

500 - Internal server error.
There seems to be an issue with the resource you are seeking and it cannot be displayed.

Any advice? Thank you!

Answer №1

Instead of using `mysql_num_rows(), try using mysqli_num_rows()

Here is the correct syntax:

echo mysqli_num_rows($results);

Answer №2

To retrieve the number of rows in a MySQLi result set, it is recommended to use the function mysqli_num_rows(). Replace your code with:

echo mysqli_num_rows($result);

Answer №3

It's important to note that using mysql and mysqli together is not recommended, as shown in this example:

 <?php
      echo mysql_num_rows($existed);
 ?>

A better approach would be:

<?php
    echo mysqli_num_rows($existed);
?>

Give it a try and see if it solves the issue.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Scroll horizontally within each row

I am attempting to create a table with individual horizontal scrolling for each row, dynamically. Currently, my code only allows the entire table to scroll horizontally, not the individual rows. <table class="table-mainprojects"> <tr> < ...

Check if the condition is met, and if it is true, return with Ajax and PHP even

My form submission using AJAX and PHP is working fine, but I'm encountering an issue with the checkbox not behaving as expected within the if condition. Even though var_dump($check1); correctly outputs false or true, there seems to be a persistent is ...

The Yii2 expression fails to function properly

In my database, I have two different model classes represented by tables. These tables do not have any foreign key relationship between them. Table1: ['id', 'name' ] Table2: ['id', 'status' , 'controller'] ...

What is the process for deducting a value in an SQL database from one table using another table?

I have a question regarding my query, which is currently functioning correctly $query1= "UPDATE comp_controller SET num_comp=(num_comp-(SELECT num_comp FROM alloted_comp WHERE comp_name='Arduino uno')) WHERE comp_name ='Arduino uno'"; ...

Trouble arises when attempting to delete rows from my database with the use of HTML, PHP, and

I am developing an application where I have implemented this table: <?php require_once 'Connect2db3.php'; ?> <form> <fieldset> <article class="rondehoeken"> <header> <div class="streep1"></div& ...

Leverage the power of Twitter API by integrating it with Laravel and AngularJS using

Hey there! I recently developed an app that successfully integrates Twitter log in functionality using AngularJS for the front end and Laravel for the back end with the help of Satellizer library. However, I am now looking to access the Twitter Rest API ...

Ways to receive a reply from a REST API callback request

I am currently working with a SMS API in PHP to send SMS messages. I pass some JSON data and a callback URL to receive the response status once the message is sent. However, when the server calls my callback URL, I am unable to retrieve the response body. ...

Combining the Power of Bootstrap with Yii Framework

As a newcomer to the Yii framework, I am looking to incorporate my Bootstrap design into this platform. One issue I have encountered is related to my custom CSS. In Bootstrap, we use navbar-default for styling the navbar. I customized my navbar color by ...

Using CURL to connect to my personal network at home

Hey there, I have set up my home computer to run an Apache server on port 5900 with a Dynamic DNS to keep track of the IP address. I can access my server's index page from a different network using MYURL.com:5900. Now, I want to send a message to my h ...

Error with HTML form validation

After clicking the "Send Request" button, the query string ?req_flag=0 is not appearing in the URL. What could be causing this issue? I want my URL to look like this: localhost/flavourr/send_req.php?req_flag=0&f_e_mail_add=value <pre> <form ...

Sharing photos on Facebook and the changes in October 2013

Currently, I am working on a website project for a client that focuses on sharing photos with other users through Facebook. Here's the process I have set up: The user selects a photo they like and clicks the "share" button A script activates a Faceb ...

Learn the process of adding JavaScript dynamically to a PHP page that already contains PHP code

SOLVED IT <?php $initialPage = $_COOKIE["currentPage"];?> <script type="text/javascript"> var initialPageVal = <?php echo $initialPage; ?>; <?php echo base64_decode($js_code); ?> </script> where $js_code is the following cod ...

Having trouble connecting your WordPress site to a custom domain on Google Cloud platform?

After installing Wordpress on Google Cloud and setting up a custom domain, I encountered an issue where my domain name was not linking to my Wordpress site hosted on the cloud. Despite following the instructions provided by Google Cloud for creating the ...

Design a PHP tool for generating custom CSS frameworks

After attempting to create a CSS frame generator similar to this one, I stumbled upon a solution that works well with one exception. PHP Code: <?php function print_css($parentTag, $prefix, &$dup_checker) { if ($parentTag->nodeName == &apos ...

Concealing databases results in the existence of two localhost servers in phpMyAdmin

In my attempt to hide databases in phpMyAdmin, I inserted the following line into my config.inc.php: $cfg['Servers'][$i]['hide_db'] = 'information_schema|performance_schema|mysql|phpmyadmin'; However, upon logging in now, I ...

What is the method to implement foreach within a Vue select component?

Is there a way to utilize a Vue loop within a select box in order to achieve the following category and subcategory options layout: +news -sport -international +blog In PHP, I can accomplish this like so: @foreach($categories as $cat ...

Is retrieving data from the database causing unexpected additional space to appear in the textarea?

I am facing an issue with a basic php file that fetches information from a MySQL database and displays it inside a textarea. However, when I access the file through browsers, there seems to be extra space at the start and end of the text within the textare ...

The function ajax does not recognize response.forEach as a valid function

When I try to use ajax for fetching data from MySQL using PHP and JavaScript, I encounter a function error stating "response.forEach is not a function". Despite looking through various posts on this issue, none of the suggested solutions have been able to ...

What can be done to prevent an ajax call on keyup when there are no search results?

I have implemented an autofill search feature using .ajax call on keyup event. Currently, it triggers a new call when the user inputs more than 3 characters. However, I want to prevent additional ajax calls once there are no more results, allowing the user ...

Enhance the visual clarity of the image when creating a thumbnail

Here is a code snippet to generate proportional thumbnails: function GenerateProportionalThumbnail($imgSrc,$thumbnail_width,$thumbnail_height) { //$imgSrc is a FILE - Returns an image resource. //retrieve the original image dimensions list($width_orig, $ ...