+ Reply to Thread
Results 1 to 5 of 5

Thread: PHP help continued...

  1. #1
    sax0n's Avatar
    sax0n is offline x10Hosting Member sax0n is an unknown quantity at this point
    Join Date
    Sep 2008
    Posts
    11

    PHP help continued...

    Right. I've been mulling this one around for a while and I have came up with this.
    PHP Code:
    <html>
    <head>
    <title> Main </title>
    </head>
    <body>
    <h3> Test </h3>
    <?php 
    $dbhost 
    'localhost';
    $dbuser 'sax0n';
    $dbpass 'password';

    mysql_connect($dbhost$dbuser$dbpass) or die('Error connecting to mysql');

    mysql_select_db("sax0n_main") or die; 

    $username 'saxon';
    $ui_query mysql_query("SELECT * FROM user_info WHERE username = '$username' LIMIT 1");
    $ui_table mysql_fetch_assoc($ui_query);
    echo 
    $ui_table[level];
    $co_long $ui_table['co_ords_long']; 

    $map_query mysql_query("SELECT * FROM map WHERE 'co_ords_long' = '$co_long' AND 'co_ords_lat' = '$co_lat' LIMIT 1"); 
    $map_table mysql_fetch_assoc($map_query);
    $player_location $map_table[name];
    echo 
    $map_table[name];
    echo 
    $player_location ;
    </
    body>
    </
    html>
    With the output...

    Test
    1

    I dont get why level echos but name doesn't! :dunno:

    Help is infinitley appreciated!
    Last edited by sax0n; 11-01-2008 at 06:48 PM. Reason: I put up my password! :p

  2. #2
    Scoochi2's Avatar
    Scoochi2 is offline x10 Sophmore Scoochi2 is an unknown quantity at this point
    Join Date
    Aug 2008
    Location
    Southport!
    Posts
    185

    Re: PHP help continued...

    should
    PHP Code:
    echo $map_table[name]; 
    be
    PHP Code:
    echo $map_table['name']; 
    ?
    If anyone can see it, my post was meant for anyone who reads it. Don't take it personally or think I'm being condescending... :nuts:

  3. #3
    mephis's Avatar
    mephis is offline x10Hosting Member mephis is an unknown quantity at this point
    Join Date
    Aug 2008
    Location
    London, UK
    Posts
    39

    Re: PHP help continued...

    Quote Originally Posted by Scoochi2 View Post
    should
    PHP Code:
    echo $map_table[name]; 
    be
    PHP Code:
    echo $map_table['name']; 
    ?
    not sure that the problem lies there (although it's a good point).

    I think the problem is in the second SQL query:
    Code:
    $map_query = mysql_query("SELECT * FROM map WHERE 'co_ords_long' = '$co_long' AND 'co_ords_lat' = '$co_lat' LIMIT 1");
    it should be:
    Code:
    $map_query = mysql_query("SELECT * FROM map WHERE co_ords_long='$co_long' AND co_ords_lat='$co_lat' LIMIT 1");
    ...no single quotes in the table field names. Try running that query on your database (say... using phpmyadmin or so) and see what it says...

  4. #4
    xPlozion's Avatar
    xPlozion is offline x10 Elder xPlozion is an unknown quantity at this point
    Join Date
    Mar 2008
    Location
    Delaware, USA
    Posts
    872

    Re: PHP help continued...

    what mephis said was right, but in your second query, you're calling $co_lat, but you haven't set the variable.
    Last edited by xPlozion; 11-01-2008 at 09:29 PM.

  5. #5
    sax0n's Avatar
    sax0n is offline x10Hosting Member sax0n is an unknown quantity at this point
    Join Date
    Sep 2008
    Posts
    11

    Re: PHP help continued...

    Yay! Thanks Mephis! That worked.

    Quote Originally Posted by xPlozion View Post
    what mephis said was right, but in your second query, you're calling $co_lat, but you haven't set the variable.
    I have but that bit got cut out when I was copy and pasting.

+ Reply to Thread

Similar Threads

  1. Ever Been Suspended For Using PHP?
    By dragoneye_xp in forum Off Topic
    Replies: 26
    Last Post: 08-16-2009, 07:17 PM
  2. [PHP] Variables in PHP
    By Bryon in forum Tutorials
    Replies: 15
    Last Post: 01-29-2009, 09:46 AM
  3. currently have an application pending php
    By biomasti in forum Free Hosting
    Replies: 1
    Last Post: 09-03-2008, 01:58 PM
  4. php errors galore
    By DMG Online in forum Scripts & 3rd Party Apps
    Replies: 9
    Last Post: 05-17-2008, 06:23 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers