Jump to content

Newbie Help


BuckeyeTheDog

Recommended Posts

Hello all. I'm a newbie to php. Just installed XAMPP on a Mac and I'm using "PHP and MySQL for Dummies"- sorry.

 

Everything is installed and running fine, but my I can't get my first exercise in accessing MySQL to work...   Here is the warning I'm receiving...

 

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /Applications/xampp/xamppfiles/htdocs/NoDamnWay.php on line 21

 

And here is my PHP...   (I've called out the offending Line 21 below...)

<?php
echo "<html>
<head><title>Test My SQL- It'll be a miracle if this works </title></head>
<body>";
$host="localhost";
$user="root";
$password="";

$cxn = mysqli_connect ($host,$user,$password);
$sql= "SHOW STATUS";
$result = mysqli_query($cxn,$sql);
if($result == false)
{
	echo "<h4>Error: ".mysqli_error($cxn)."</h4>";
	}
	else	
	{
	echo "<table border='1'>
	<tr><th>Variable_name</th>
		<th>Value</th></tr>";
/*LINE 21*/	for($i = 0; $i < mysql_num_rows($result); $i++)	
	{
		echo "<tr>";
		$row_array = mysqli_fetch_row($result);
	for($j = 0;$j < mysqli_num_fields($result);$j++)
		{
			echo "<td>".$row_array[$j]."</td>\n";
			}
			}
	echo "</table>";
	}
	?>
       </body></html>

 

Thanks for helping a newbie!!!

Link to comment
Share on other sites

oh haha i get it the script does it i guess i should have actually paid more attention my bad.

 

Anytime I can call out an admin/mod's mistake I'm happy :)

 

haha hey now admin/mod does not always equal smartest people around...

Thanks for the help.  

 

My wife also pointed out the I was missing the "i" in the "mysqli_num_rows".  We fixed that and it is working fine...

 

You guys were great with such quick responses....    :)

 

Tell your wife she has a good "i" for detail :P

Link to comment
Share on other sites

just a note the mysqli is a new version of mysql library of functions.  A lot of old timers php/mysqlers still use the older mysql library and u might find more support out there.

 

Also I'd throw that book out cause its a piece of crap if its teaching you to program like that.

 

Thirdly what editor do u use to write in?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.