NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming
Reload this Page Whats wrong with this? (searching database for specific id)

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.

Advanced Search


Closed Thread
 
LinkBack Thread Tools
Old 02-23-2007, 06:16 PM THREAD STARTER               #1 (permalink)
Senior Member
 
killaklown's Avatar
Join Date: Oct 2003
Posts: 3,472
killaklown is a splendid one to beholdkillaklown is a splendid one to beholdkillaklown is a splendid one to beholdkillaklown is a splendid one to beholdkillaklown is a splendid one to beholdkillaklown is a splendid one to beholdkillaklown is a splendid one to beholdkillaklown is a splendid one to behold
 



Whats wrong with this? (searching database for specific id)


This is the code which im having problems with (its not all the code, so i am not missing the <?php, or a })

Code:
    $sql_query = "SELECT * FROM links WHERE id='$id'";
    //store the SQL query in the result variable
    $result = mysql_query($sql_query);

    if(mysql_num_rows($result))
    {
    //output as long as there are still available fields
    while($row = mysql_fetch_array($result))
    {
        $title = $row["title"];
        $url = $row["url"];
        $id = $row["id"];
        $status = $row["status"];
		$email = $row["email"];
   }

Im trying to get it to let you edit the information in the 'links' part of the database. The page before has this code:

Code:
<a href=\"editlink.php?id=$id\">Edit</a>
The id is right and everything, but the page always shows it as blank. I had it working a long time ago, then kind of forgot about it and now it doesnt work.
killaklown is offline  
Old 02-23-2007, 07:29 PM   #2 (permalink)
NamePros Regular
 
shreder's Avatar
Join Date: Mar 2006
Posts: 780
shreder is a name known to allshreder is a name known to allshreder is a name known to allshreder is a name known to allshreder is a name known to allshreder is a name known to allshreder is a name known to allshreder is a name known to all
 


Protect Our Planet
Try this:

<a href=\"editlink.php?id=<?= $id ?>\">Edit</a>
__________________
EKED.COM BDPU.COM FFHF.COM BXNN.COM SFUZ.COM OOHH.NET EOEI.COM NSTO.COM SPMQ.COM CODV.COM - Pm Offers
"What doesn't kill you only makes you stronger..."
shreder is offline  
Old 02-24-2007, 12:40 AM   #3 (permalink)
NamePros Regular
Join Date: Apr 2004
Location: NL
Posts: 808
Slewey is just really niceSlewey is just really niceSlewey is just really niceSlewey is just really nice
 



aren't you forgetting to get the id from the link?
try this query
PHP Code:
SELECT FROM links WHERE id='".$_GET['id']."'"; 
or you shloud define your variable id before executing the query
PHP Code:
$id $_GET['id'];

    
$sql_query "SELECT * FROM links WHERE id='$id'";
    
//store the SQL query in the result variable
    
$result mysql_query($sql_query);

    if(
mysql_num_rows($result))
    {
    
//output as long as there are still available fields
    
while($row mysql_fetch_array($result))
????: NamePros.com http://www.namepros.com/programming/297903-whats-wrong-searching-database-specific-id.html
    {
        
$title $row["title"];
        
$url $row["url"];
????: NamePros.com http://www.namepros.com/showthread.php?t=297903
        
$id $row["id"];
        
$status $row["status"];
        
$email $row["email"];
   } 
Slewey is offline  
Old 02-24-2007, 09:57 AM THREAD STARTER               #4 (permalink)
Senior Member
 
killaklown's Avatar
Join Date: Oct 2003
Posts: 3,472
killaklown is a splendid one to beholdkillaklown is a splendid one to beholdkillaklown is a splendid one to beholdkillaklown is a splendid one to beholdkillaklown is a splendid one to beholdkillaklown is a splendid one to beholdkillaklown is a splendid one to beholdkillaklown is a splendid one to behold
 



Originally Posted by Slewey
aren't you forgetting to get the id from the link?
????: NamePros.com http://www.namepros.com/showthread.php?t=297903
try this query
PHP Code:
SELECT FROM links WHERE id='".$_GET['id']."'"; 

Haha, thanks slewey, i knew it was something to do with that line.

Rep added. I see the rep also got you another green bar
killaklown is offline  
Old 02-24-2007, 10:20 AM   #5 (permalink)
Senior Member
Join Date: Dec 2006
Location: England
Posts: 1,568
Matthew. has much to be proud ofMatthew. has much to be proud ofMatthew. has much to be proud ofMatthew. has much to be proud ofMatthew. has much to be proud ofMatthew. has much to be proud ofMatthew. has much to be proud ofMatthew. has much to be proud ofMatthew. has much to be proud of
 


Adoption Breast Cancer Breast Cancer Cancer Survivorship
Please remember to validate and secure your inputs folks, killaklown remember that is extremely insecure as it is right now

Just my piece of advice although the problem is solved

Matt
Matthew. is offline  
Old 02-25-2007, 11:52 AM   #6 (permalink)
NamePros Regular
Join Date: Apr 2004
Location: NL
Posts: 808
Slewey is just really niceSlewey is just really niceSlewey is just really niceSlewey is just really nice
 



Originally Posted by killaklown
Haha, thanks slewey, i knew it was something to do with that line.
????: NamePros.com http://www.namepros.com/showthread.php?t=297903

Rep added. I see the rep also got you another green bar
np
Slewey is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


Liquid Web Smart Servers  
All times are GMT -7. The time now is 09:44 AM.

Managed Web Hosting by Liquid Web
Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger