Problem getting info from webpage url

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
hubble121
Forum Newbie
Posts: 6
Joined: Mon Oct 11, 2004 12:49 pm

Problem getting info from webpage url

Post by hubble121 »

Hi im having a really simple problem - im new to php.

Ok on an url like .../test.php?id=4656

im trying to get php to get the value of the id, the id is the MemberID in the database. Then i want to find the record in the database that matches thes MemberID (i.e. 4656) and then find the Username of that record. The username will then be defined by $UplineMember see code below.

Code: Select all

$id = $_GETїid];
 $sql = "SELECT Username FROM $sqltable WHERE MemberID='$id'";
 $sql_result = mysql_query ($sql, $connection ) or die ('request "Could not execute SQL query - testing "');
 list ($UplineMember) = mysql_fetch_row($sql_result);
Trouble is, that its not working :cry:

Please help? :D

Chris Hubble
User avatar
mudkicker
Forum Contributor
Posts: 479
Joined: Wed Jul 09, 2003 6:11 pm
Location: Istanbul, TR
Contact:

Post by mudkicker »

change in sql query

-> ... WHERE MemberID=$id
hubble121
Forum Newbie
Posts: 6
Joined: Mon Oct 11, 2004 12:49 pm

Post by hubble121 »

Thanks

but now i get an error message as follows

request "Could not execute SQL query - testing "

Thanks

Chris Hubble
User avatar
mudkicker
Forum Contributor
Posts: 479
Joined: Wed Jul 09, 2003 6:11 pm
Location: Istanbul, TR
Contact:

Post by mudkicker »

is in database structure MemberID defined as "int" (integer) ?
are the column names etc. right?
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: Problem getting info from webpage url

Post by John Cartwright »

Try this

Code: Select all

<?php

$sql = "SELECT `Username` FROM `$sqltable` WHERE `MemberID`='".$_GET['id']."'";

$result = mysql_query($sql) or die(mysql_error());

$row = mysql_fetch_assoc($result);

echo $row['username'];

?>
notice you should always use [php_man]mysql_error()[/php_man]
hubble121
Forum Newbie
Posts: 6
Joined: Mon Oct 11, 2004 12:49 pm

Post by hubble121 »

MemberID is set as int(8), unsigned

the column names are correct

Thanks for your help
hubble121
Forum Newbie
Posts: 6
Joined: Mon Oct 11, 2004 12:49 pm

Post by hubble121 »

sorry i made a smiley by accident, int 8, unsigned
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

hubble121 wrote:sorry i made a smiley by accident, int 8, unsigned
Have you tried my example?
hubble121
Forum Newbie
Posts: 6
Joined: Mon Oct 11, 2004 12:49 pm

Post by hubble121 »

Phenom

I tried your method that put the username on screen - that works fine but when i do this;

Code: Select all

$sql = "SELECT `Username` FROM `$sqltable` WHERE `MemberID`='".$_GET&#1111;'id']."'";
 $result = mysql_query($sql) or die(mysql_error());
 $row = mysql_fetch_assoc($result);
 $UplineMember = $row&#1111;'Username'];
$UplineMember does not equal the Username

Please help

CHris Hubble
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

What?
Post Reply