What's wrong with this PHP code?

Status
Not open for further replies.

JoshuaLuke

Posting Freak
Jan 29, 2012
529
51
Hi,

I'm trying to display something on my ME page which is only avalible for non-vip users. I have this code:
Code:
 <?PHP
 
if(mysql_result(mysql_query("SELECT `vip` FROM `users` WHERE username='{username}'"), 0) == 1){
 
?>
then I have the message, then after the message I have
Code:
<?PHP
}
?>

but it's throwing me an error of

Warning
: mysql_result() [
]: Unable to jump to row 0 on MySQL result index 27 in
C:\xampp\htdocs\app\tpl\skins\Habbo\me.php
on line
165

How to fix?
 

xHissy

PHP / VB.net Developer
Oct 23, 2011
75
5
Try this:
PHP:
<?PHP
 
$query="SELECT `vip` FROM `users` WHERE username='{username}";
    $result = mysql_query($query);
    $row = mysql_num_rows($result);
    if ($row == -0){
?>
'//Stuff here!!!
<?php
    }
    ?>
 

JoshuaLuke

Posting Freak
Jan 29, 2012
529
51
Try this:
PHP:
<?PHP
 
$query="SELECT `vip` FROM `users` WHERE username='{username}";
    $result = mysql_query($query);
    $row = mysql_num_rows($result);
    if ($row != 1){
?>
'//Stuff here!!!
<?php
    }
    ?>

I'm trying to display a message to a non-vip user :L
 

Snow

New Member
Dec 10, 2011
21
5
First of all is {username} even defined?

It's supposed to be

PHP:
<?php
$_username = "Usernamelmaddfdfds";
 
$_q = mysql_query("SELECT vip FROM users WHERE username = '{$_username}'");
 
if (mysql_result($_q) == 1)
{
    //code here
}
?>
 

Dzetki

The Prodigal Son Returns
Jul 16, 2010
990
220
Hi,

I'm trying to display something on my ME page which is only avalible for non-vip users. I have this code:
Code:
 <?PHP
 
if(mysql_result(mysql_query("SELECT `vip` FROM `users` WHERE username='{username}'"), 0) == 1){
 
?>
then I have the message, then after the message I have
Code:
<?PHP
}
?>

but it's throwing me an error of


Warning

: mysql_result() [


]: Unable to jump to row 0 on MySQL result index 27 in

C:\xampp\htdocs\app\tpl\skins\Habbo\me.php

on line

165



How to fix?
what about

PHP:
 <?PHP
 
if(mysql_result(mysql_query("SELECT `vip` FROM `users` WHERE username='{username}'"), 0) == 1) {
echo "
stuff here
";
}
?>
Not sure if this is how you want it tho. But it'll do the trick aslong as you're putting the stuff within the "s.
 

JoshuaLuke

Posting Freak
Jan 29, 2012
529
51
Try this:
PHP:
<?PHP
 
$query="SELECT `vip` FROM `users` WHERE username='{username}";
    $result = mysql_query($query);
    $row = mysql_num_rows($result);
    if ($row == -0){
?>
'//Stuff here!!!
<?php
    }
    ?>

I now get
Warning
: mysql_num_rows() expects parameter 1 to be resource, boolean given in
C:\xampp\htdocs\app\tpl\skins\Habbo\me.php
on line
168
 
Status
Not open for further replies.

Users who are viewing this thread

Top