Jump to content

Who has the highest field


eazyefolife

Recommended Posts

Might want to post your code then.

<?php 
$host "xx.xx.xx.xx" // Blocked for safety
$user "x"  // Blocked for safety
$password "x"  // Blocked for safety
$db "x" // Blocked for safety
mysql_connect($host,$user,$password);
mysql_selectdb($db);
mysql_query("SELECT * FROM users ORDER BY Kills DESC LIMIT 1");

?>

 

Obviously I blocked all the regular stuff with x's. Check out my code and tell me what's wrong.  :shrug:

 

Link to comment
Share on other sites

Strangly I managed to fix it. Now how would I make it show:

 

$msg = mysql_query("SELECT * FROM users ORDER BY Kills DESC LIMIT 1");
echo $msg;

 

Like that?

 

Well, you'd normally place it into a variable so you can go over the rows:

$q =  mysql_query("SELECT * FROM users ORDER BY Kills DESC LIMIT 1");

while($row = mysql_fetch_array($q)){ 
       echo '<pre>';
       echo print_r($row);
}

 

That can give you a better idea of what you're doing.

Link to comment
Share on other sites

Strangly I managed to fix it. Now how would I make it show:

 

$msg = mysql_query("SELECT * FROM users ORDER BY Kills DESC LIMIT 1");
echo $msg;

 

Like that?

 

Well, you'd normally place it into a variable so you can go over the rows:

$q =  mysql_query("SELECT * FROM users ORDER BY Kills DESC LIMIT 1");

while($row = mysql_fetch_array($q)){ 
       echo '<pre>';
       echo print_r($row);
}

 

That can give you a better idea of what you're doing.

 

nothing wont show up

 

Link to comment
Share on other sites

You don't need a while loop because your only selecting one row.

 

<?php 
$host "xx.xx.xx.xx" // Blocked for safety
$user "x"  // Blocked for safety
$password "x"  // Blocked for safety
$db "x" // Blocked for safety
mysql_connect($host,$user,$password);
mysql_select_db($db);
if ($result = mysql_query("SELECT * FROM users ORDER BY Kills DESC LIMIT 1")) {
  if (mysql_num_rows($result)) {
    $row = mysql_fetch_array($result);
    print_r($row);
  } else {
    echo "No results found";
  }
} else {
  trigger_error(mysql_error());
}
?>

Link to comment
Share on other sites

You don't need a while loop because your only selecting one row.

 

<?php 
$host "xx.xx.xx.xx" // Blocked for safety
$user "x"  // Blocked for safety
$password "x"  // Blocked for safety
$db "x" // Blocked for safety
mysql_connect($host,$user,$password);
mysql_select_db($db);
if ($result = mysql_query("SELECT * FROM users ORDER BY Kills DESC LIMIT 1")) {
  if (mysql_num_rows($result)) {
    $row = mysql_fetch_array($result);
    print_r($row);
  } else {
    echo "No results found";
  }
} else {
  trigger_error(mysql_error());
}
?>

 

Now only ?> is showing on the web page.. (( Bug? ))

Link to comment
Share on other sites

Is your server configured to parse php? It would appear not.

 

what?

 

We're wondering why it would display the PHP source in the first place. Are you viewing the file directly on web browser by chance?

(IE: C:\files\this.php)

 

And as well, is it .php? Web servers are not really configured to run them off default extensions like .phtml etc.

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.