FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


cant grab 2nd var





m-productions
ok heres my code

Code:

<?php
session_start();
$user = $_POST['player'];



require_once("dbDetails.php");

$safe_user = mysql_real_escape_string($user);

$SQL = "SELECT * FROM game WHERE player ='$safe_user'";

$rs = mysql_query($SQL,$conn);



define('CHARACTER_INDEX', 2);
$x = mysql_result($rs, 0, CHARACTER_INDEX);
echo '&x='.$x.'&';
define('CHARACTER_INDEX', 3);
$y = mysql_result($rs, 0, CHARACTER_INDEX);
echo '&x='.$y.'&'; 



?>


it echos x as being 90 (which is correct)
and echos y as undefined (which is not right)



i also tried this

Code:

<?php
session_start();
$user = $_POST['player'];



require_once("dbDetails.php");

$safe_user = mysql_real_escape_string($user);

$SQL = "SELECT * FROM game WHERE player ='$safe_user'";

$rs = mysql_query($SQL,$conn);
$x  =  mysql_result($rs, 0, 1);
$y  =  mysql_result($rs, 0, 2);
echo '&x='.$x.'&';
echo '&x='.$y.'&';







?>


once again..only X is being echoed...Y is still undifeined.....





I GOT IT TO WORK
Code:

<?php
session_start();
$user = $_POST['player'];



require_once("dbDetails.php");

$safe_user = mysql_real_escape_string($user);

$SQL = "SELECT * FROM game WHERE player ='$safe_user'";
$newSQL = "SELECT * FROM game WHERE player ='$safe_user'";

$rs = mysql_query($SQL,$conn);
$rss = mysql_query($newSQL,$conn);


define('CHARACTER_INDEX', 2);
$x = mysql_result($rs, 0, CHARACTER_INDEX);
echo '&x='.$x.'&';
$y = mysql_result($rss, 0, 3);
echo '&y='.$y.'&'; 



?>


however... I KNOW there must be a less complex way....
MrBlueSky
Try:

Code:

<?php
session_start();
$user = $_POST['player'];

require_once("dbDetails.php");

$safe_user = mysql_real_escape_string($user);

$SQL = "SELECT * FROM game WHERE player ='$safe_user'";

$rs = mysql_query($SQL,$conn);

$arr = mysql_fetch_row($rs);
$x = $arr[2];
$y = $arr[3];
echo '&x='.$x.'&';
echo '&y='.$y.'&';

?>
xyclone
MrBlueSky wrote:
Try:

Code:

<?php
session_start();
$user = $_POST['player'];

require_once("dbDetails.php");

$safe_user = mysql_real_escape_string($user);

$SQL = "SELECT * FROM game WHERE player ='$safe_user'";

$rs = mysql_query($SQL,$conn);

$arr = mysql_fetch_row($rs);
$x = $arr[2];
$y = $arr[3];
echo '&x='.$x.'&';
echo '&y='.$y.'&';

?>



how bout this one..


$SQL = "SELECT * FROM game WHERE player ='$safe_user' limit 0,2";
MrBlueSky
xyclone wrote:

how bout this one..


$SQL = "SELECT * FROM game WHERE player ='$safe_user' limit 0,2";


Why would you limit the result-set to three rows if you only use the first row (and get just one row anyway) Question
Related topics
Cant see my 2nd domain
Man Utd finish 2nd, Arsenal steal 4th
AJAX tutorial [2nd part now updated]
Microsoft bug ,Grab @Live.com domain email
Problem after phpBB installation, cant enter panel admin
Video Editing Tutorial needed. Paying 800 Fri$
Cant access admin area after updateing to 2.0.15
CANT UPLOAD .htaccess, .htpasswd, .header, .footer
I cant access my forum account HERE!!!
I cant Admin my site
i cant enter in my count
cant build site using flash (swf) on frihost
I cant enter Frihost and my web site from home
Now You Can See Ur Home
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.