/    Sign up×
Community /Pin to ProfileBookmark

Hello,

I have apache running locally and my website works fine, however, on the remote server it is not working….

I get the error

Warning: mysql_result(): supplied argument is not a valid MySQL result resource in //user.php on line 225

I am not sure why I am getting this error, can someone please help?

[code]
<?php

session_start();
$connection = mysql_connect(‘localhost’, ‘root’, ”);

//Let us know if something is wrong with the connection
if(!$connection){
die(‘Could not connect: ‘ . mysql_error());
}

//Puts Session values into variables
$email=$_SESSION[’email’];
$password=$_SESSION[‘password’];
$userId=$_SESSION[‘userId’];
$username=$_SESSION[‘username’];

//ensures session credentials have been entered./
if(!isset($_SESSION[’email’]) || !isset($_SESSION[‘password’])){
header(“Location: ./login.html”);
}

//Let us know if something is wrong with the connection
if(!$connection){
die(‘Could not connect: ‘ . mysql_error());
}

?>

<?php
mysql_select_db(“winelist”,$connection);
//select all the wines user has rated
$userRatings=”SELECT image,wineName,wineYear,varietal,appearance, aroma, body, taste, finish, ratings, wineId FROM wines
WHERE userId=’$userId'”;
$userQuery = mysql_query($userRatings);

//display the wines

//Gets us the number of ratings
$numberOfRatings = “SELECT wineName FROM wines WHERE userid=’$userId'”;
$ratingResult = mysql_query($numberOfRatings);
$totalRatings = mysql_num_rows($ratingResult);

echo (“<p> Number of Ratings: ” . $totalRatings . “</p>”);
?><table>
<tr>
<td>image</td>
<td>Wine Name</td>
<td>Wine Year</td>
<td>Varietal</td>
<td>Aroma</td>
<td>Appearance</td>
<td>Body</td>
<td>Taste</td>
<td>Finish</td>
</tr>

<?php

for($i=0;$i < $totalRatings; $i++){

echo(“<form name=’edit’ action=’editwine.php’ method=’post’>”);
echo(“<input type=’hidden’ value='” . mysql_result($userQuery,$i,’wineId’) . “‘ name=’wineId’>”);

echo(“<tr>” . “<td>”);
echo(“<img src ='” . mysql_result($userQuery,$i,’image’) . “‘width=60 height=180>”);

echo(“<td>”);
echo(mysql_result($userQuery,$i,’wineName’));

echo(“<td>”);
echo(mysql_result($userQuery,$i,’wineYear’));

echo(“<td>”);
echo(mysql_result($userQuery,$i,’varietal’));

echo(“<td>”);

echo(mysql_result($userQuery,$i,’aroma’));

echo(“<td>”);
echo(mysql_result($userQuery,$i,’appearance’));

echo(“<td>”);
echo(mysql_result($userQuery,$i,’body’));

echo(“<td>”);
echo(mysql_result($userQuery,$i,’taste’));

echo(“<td>”);
echo(mysql_result($userQuery,$i,’finish’));

echo(“<div id=’edit’><td>”);
echo(“<input type = ‘submit’ value=’edit’ style=’width:50px;’>”);

echo(“</form> </tr> </td>”);
}
echo(“</table>”)

?>
[CODE]

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@NogDogJun 26.2011 — That kind of error almost always means (when it's not just a simple typo) that MySQL was not able to process the query due to some syntax error or an invalid entity name. So check to see if any of the mysql_query() calls are returning false, and if so use mysql_query() to help find out what it's complaining about.
×

Success!

Help @lrbarahona spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...