homepage Welcome to WebmasterWorld Guest from 50.17.66.61
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Mysql not pulling data?
jay7981

5+ Year Member



 
Msg#: 3906982 posted 9:37 am on May 5, 2009 (gmt 0)

i have a php page that should display results of a mysql query inside a table ... however no matter how many entries i have in the table it wont display any results
i have checked and verified the login data several times over it is all correct

i have also verified that all fields are correct and matching.

and i am getting 1 error:
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in index.php on line 10

please help

connect.php
[code=php]
<?php
$hostname='######';
$user='######';
$pass='######';
$dbase='######';
$connection = mysql_connect("$hostname" , "$user" , "$pass")
or die ("Can't connect to MySQL");
$db = mysql_select_db($dbase , $connection) or die ("Can't select database.");
?>
[/code]

index.php
[code=php]
<?php

error_reporting(E_ALL);
ini_set('display_errors', 'On');

include("connect.php");

$query = "SELECT * FROM join";
$result = mysql_query($query);
$num = mysql_num_rows ($result);

if ($num > 0 ) {
$i=0;
while ($i < $num) {
$id = mysql_result($result,$i,"ID");
$tagid = mysql_result($result,$i,"tagid");
$tsname = mysql_result($result,$i,"tsname");
$boatname = mysql_result($result,$i,"boatname");
$blevel = mysql_result($result,$i,"blevel");
$plevel = mysql_result($result,$i,"plevel");
$ep = mysql_result($result,$i,"ep");
$firstname = mysql_result($result,$i,"firstname");
$lastname = mysql_result($result,$i,"lastname");
$country = mysql_result($result,$i,"country");
$email = mysql_result($result,$i,"email");
$age = mysql_result($result,$i,"age");
$guild = mysql_result($result,$i,"guild");
$otherboats = mysql_result($result,$i,"otherboats");
$comments = mysql_result($result,$i,"comments");
$ip = mysql_result($result,$i,"ip");
$rank = mysql_result($result,$i,"rank");

echo "<b>ID:</b> $id<br>";
echo "<b>Boat ID:</b> $tagid<br>";
echo "<b>TS Name:</b> $tsname<br>";
echo "<b>Boat Name:</b> $boatname<br>";
echo "<b>Boat Level:</b> $blevel<br>";
echo "<b>Pirate Level:</b> $plevel<br>";
echo "<b>EP:</b> $ep<br>";
echo "<b>First Name:</b> $firstname<br>";
echo "<b>Last Name:</b> $lastname<br>";
echo "<b>Country:</b> $country<br>";
echo "<b>Email:</b> $email<br>";
echo "<b>Age:</b> $age<br>";
echo "<b>Guild:</b> $guild<br>";
echo "<b>Other Boats:</b> $otherboats<br>";
echo "<b>Comments:</b> $comments<br>";
echo "<b>IP:</b> $ip<br>";
echo "<b>Rank:</b> $rank<br>";
echo "<a href=\"update.php?id=$id\">Update</a> - <a href=\"delete.php?id=$id\">Delete</a>";
echo "<br><br>";

++$i; } } else { echo "The database is empty"; }
mysql_close();
?>
<br>
<a href="add.php">Add entry</a>
[/code]

i even tried to simplify it using

[code=php]
<?php
include("connect.php");

$query = "SELECT * FROM join";
$result = mysql_query($query);
$num = mysql_num_rows ($result);

echo $query;
echo $result;
mysql_close();
?>
[/code]

and still no display of results ... puzzuling

 

Frank_Rizzo

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 3906982 posted 11:40 am on May 5, 2009 (gmt 0)

The word 'join' is a reserved word for mysql. Try renaming the table and editing your script.

le_gber

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 3906982 posted 3:52 pm on May 8, 2009 (gmt 0)

also what happens if you have this?

$result = mysql_query($query,$connection);

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved