ERROR EVEN TRIED MANY TIME

		<?php
				$SQLSELECT = "SELECT * FROM nov ";
				$result_set =  mysqli_query($SQLSELECT, $conn);
				while($row = mysqli_fetch_array($result_set))
				{
				?>
			
					<tr>
						<td><?php echo $row['name']; ?></td>
						<td><?php echo $row['cpu_count']; ?></td>
						<td><?php echo $row['memory_size']; ?></td>
						<td><?php echo $row['disk_space_size']; ?></td>
						<td><?php echo $row['nic_count']; ?></td>
						<td><?php echo $row['power_state']; ?></td>
					</tr>
				<?php

Open in new window


ERROR : Warning: mysqli_query() expects parameter 1 to be mysqli, string given in C:\xampp\htdocs\display\index.php on line 78

Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, null given in C:\xampp\htdocs\display\index.php on line 79
Name      CPUCOUNT      MEMORYSIZE      DISKSPACESIZE      NICCOUNT      POWERSTATE
Scott Yong Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

gr8gonzoConsultantCommented:
Switch the order of $conn and your query so $conn is first:
$result_set =  mysqli_query($conn, $SQLSELECT);
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Dave BaldwinFixer of ProblemsCommented:
As shown in the Procedural style example on this page http://php.net/manual/en/mysqli.query.php , you have to make the connection first with mysqli_connect() .  I don't see that in your example.  You have to do that on each PHP page that you load.  If you did it on a previous page, it does not count for the current page.
0
Scott Yong Author Commented:
That 1 success already but its appear on other coding
Notice: Undefined offset: 6 in C:\xampp\htdocs\display\import.php on line 18

Fatal error: Uncaught Error: Call to undefined function mysql_query() in C:\xampp\htdocs\display\import.php:20 Stack trace: #0 {main} thrown in C:\xampp\htdocs\display\import.php on line 20


<?php
include 'db.php';
if(isset($_POST["Import"])){
		

		echo $filename=$_FILES["file"]["tmp_name"];
		

		 if($_FILES["file"]["size"] > 0)
		 {

		  	$file = fopen($filename, "r");
	         while (($emapData = fgetcsv($file, 10000, ",")) !== FALSE)
	         {
	    
	          //It wiil insert a row to our subject table from our csv file`
	           $sql = "INSERT into subject (`(`name`, `cpu_count`, `memory_size`, `disk_space_size`,`nic_count`, `power_state`) 
	            	values('$emapData[1]','$emapData[2]','$emapData[3]','$emapData[4]','$emapData[5]','$emapData[6]')";
	         //we are using mysql_query function. it returns a resource on true else False on error
	          $result = mysql_query( $sql, $conn );
				if(! $result )
				{
					echo "<script type=\"text/javascript\">
							alert(\"Invalid File:Please Upload CSV File.\");
							window.location = \"index.php\"
						</script>";
				
				}

Open in new window

0
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

gr8gonzoConsultantCommented:
That is a different error. Please open a separate question for the new error and mark this one as solved to avoid confusion.
0
Scott Yong Author Commented:
okay .. i will post new question
0
gr8gonzoConsultantCommented:
Actually, I'm done for the evening, so here are my comments for your next 2 questions ahead of time (since your new question isn't posted just yet):

Okay, so first the undefined offset problem is simply the result of you starting your array indexes at 1. In PHP, arrays start at zero, so the first element in your array is $emapData[0], not $emapData[1]. So the error is saying that there is no index "6", which means  $emapData[6] doesn't exist. To solve this, just shift all your index numbers down by one so your last element is $emapData[5], not $emapData[6].

The second problem:
Call to undefined function mysql_query()

...is due to the deprecation of the mysql_ functions. You should be using mysqli_ functions instead, like you did in the first script you had.
1
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.