[advanced search]
 

Go Back   NamePros.com > Discussion > Web Design & Development > Programming

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


Closed Thread
 
LinkBack Thread Tools
Old 02-23-2007, 05:16 PM   #1 (permalink)
Senior Member
 
Join Date: Oct 2003
Location: Winnipeg, Canada
Posts: 3,472
5.31 NP$ (Donate)

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 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, 06:29 PM   #2 (permalink)
NamePros Regular
 
shreder's Avatar
 
Join Date: Mar 2006
Posts: 779
5.00 NP$ (Donate)

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 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-23-2007, 11:40 PM   #3 (permalink)
NamePros Regular
 
Join Date: Apr 2004
Location: NL
Posts: 827
316.85 NP$ (Donate)

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))
    {
        
$title = $row["title"];
        
$url = $row["url"];
        
$id = $row["id"];
        
$status = $row["status"];
        
$email = $row["email"];
   }
__________________
xmpv.com | nuwp.com | frot.info |
Slewey is offline  
Old 02-24-2007, 08:57 AM   #4 (permalink)
Senior Member
 
Join Date: Oct 2003
Location: Winnipeg, Canada
Posts: 3,472
5.31 NP$ (Donate)

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 behold


Quote:
Originally Posted by Slewey
aren't you forgetting to get the id from the link?
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, 09:20 AM   #5 (permalink)
Stud Sausage
 
Join Date: Dec 2006
Location: England
Posts: 1,546
34.41 NP$ (Donate)

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
__________________
My NamePros Tools
(firefox plugin, google gadget etc)
Matthew. is offline  
Old 02-25-2007, 10:52 AM   #6 (permalink)
NamePros Regular
 
Join Date: Apr 2004
Location: NL
Posts: 827
316.85 NP$ (Donate)

Slewey is just really niceSlewey is just really niceSlewey is just really niceSlewey is just really nice


Quote:
Originally Posted by killaklown
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
np
__________________
xmpv.com | nuwp.com | frot.info |
Slewey is offline  
Closed Thread


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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Site Sponsors
Advertise your business at NamePros

All times are GMT -7. The time now is 04:09 AM.


Powered by: vBulletin® Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0
Template-Modifications by TMS
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85