Page 1 of 1

Problem getting info from webpage url

Posted: Mon Oct 11, 2004 12:56 pm
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

Posted: Mon Oct 11, 2004 1:04 pm
by mudkicker
change in sql query

-> ... WHERE MemberID=$id

Posted: Mon Oct 11, 2004 1:15 pm
by hubble121
Thanks

but now i get an error message as follows

request "Could not execute SQL query - testing "

Thanks

Chris Hubble

Posted: Mon Oct 11, 2004 1:20 pm
by mudkicker
is in database structure MemberID defined as "int" (integer) ?
are the column names etc. right?

Re: Problem getting info from webpage url

Posted: Mon Oct 11, 2004 1:24 pm
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]

Posted: Mon Oct 11, 2004 1:40 pm
by hubble121
MemberID is set as int(8), unsigned

the column names are correct

Thanks for your help

Posted: Mon Oct 11, 2004 1:44 pm
by hubble121
sorry i made a smiley by accident, int 8, unsigned

Posted: Mon Oct 11, 2004 1:44 pm
by John Cartwright
hubble121 wrote:sorry i made a smiley by accident, int 8, unsigned
Have you tried my example?

Posted: Mon Oct 11, 2004 1:55 pm
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

Posted: Mon Oct 11, 2004 3:01 pm
by John Cartwright
What?