Connecting Tech Pros Worldwide Help | Site Map

Can anyone help me with this problem please....?

  #1  
Old July 17th, 2005, 03:15 PM
toedipper
Guest
 
Posts: n/a
Hello,

The following code grabs the url of a file location on the net from a db
on my server for a file download.


// connection to grab url of the file
mysql_select_db($database_local, $local);
$query_dllink = sprintf("SELECT dllink FROM software WHERE swid =
%s",$colname_dllink);
$dllink = mysql_query($query_dllink, $local) or die(mysql_error());
$row_dllink = mysql_fetch_assoc($dllink);
$totalRows_dllink = mysql_num_rows($dllink);
?>

So I've gone and grabbed the location.

I then stick this following bit in between the header sections on my
html page, note I am trying to kick of the download.

<? echo "<META HTTP-EQUIV=\"refresh\" CONTENT=\"6;
URL=http://\"$dllink\" \">"; ?>

This all work on paper but nothing happens. Basically I want to grab a
file location url from my db and then start to download that file to the
user. I am not sure if I am doing this right at all so help would be
appreciated.

Any ideas?

tia.

td.
  #2  
Old July 17th, 2005, 03:15 PM
Peter van Schie
Guest
 
Posts: n/a

re: Can anyone help me with this problem please....?


toedipper wrote:[color=blue]
>
> <? echo "<META HTTP-EQUIV=\"refresh\" CONTENT=\"6;
> URL=http://\"$dllink\" \">"; ?>
>
> This all work on paper but nothing happens. Basically I want to grab a
> file location url from my db and then start to download that file to the
> user. I am not sure if I am doing this right at all so help would be
> appreciated.[/color]

Hi toedipper,

Why are you adding double-quotes around the $dllink variable?
Try: <? echo "<META HTTP-EQUIV=\"refresh\" CONTENT=\"6;
URL=http://$dllink\">"; ?>

Also have you tried using header():

header('Location: http://' . $dllink);

Make sure to not output anything to the browser before calling header().

--
http://www.phpforums.nl
  #3  
Old July 17th, 2005, 03:15 PM
toedipper
Guest
 
Posts: n/a

re: Can anyone help me with this problem please....?


Peter van Schie wrote:[color=blue]
> toedipper wrote:
>[color=green]
>>
>> <? echo "<META HTTP-EQUIV=\"refresh\" CONTENT=\"6;
>> URL=http://\"$dllink\" \">"; ?>
>>
>> This all work on paper but nothing happens. Basically I want to grab a
>> file location url from my db and then start to download that file to
>> the user. I am not sure if I am doing this right at all so help would
>> be appreciated.[/color]
>
>
> Hi toedipper,
>
> Why are you adding double-quotes around the $dllink variable?
> Try: <? echo "<META HTTP-EQUIV=\"refresh\" CONTENT=\"6;
> URL=http://$dllink\">"; ?>
>
> Also have you tried using header():
>
> header('Location: http://' . $dllink);
>
> Make sure to not output anything to the browser before calling header().
>[/color]
Hello Peter,

Tried the two suggestion but still no joy. The page just sits there and
nothing happens. Am I correct in assuming that $dllink will correctly
pick up the url from my db?

Thanks,

td.
  #4  
Old July 17th, 2005, 03:15 PM
Jerry Stuckle
Guest
 
Posts: n/a

re: Can anyone help me with this problem please....?


toedipper wrote:[color=blue]
> Hello,
>
> The following code grabs the url of a file location on the net from a db
> on my server for a file download.
>
>
> // connection to grab url of the file
> mysql_select_db($database_local, $local);
> $query_dllink = sprintf("SELECT dllink FROM software WHERE swid =
> %s",$colname_dllink);
> $dllink = mysql_query($query_dllink, $local) or die(mysql_error());
> $row_dllink = mysql_fetch_assoc($dllink);
> $totalRows_dllink = mysql_num_rows($dllink);
> ?>
>
> So I've gone and grabbed the location.
>
> I then stick this following bit in between the header sections on my
> html page, note I am trying to kick of the download.
>
> <? echo "<META HTTP-EQUIV=\"refresh\" CONTENT=\"6;
> URL=http://\"$dllink\" \">"; ?>
>
> This all work on paper but nothing happens. Basically I want to grab a
> file location url from my db and then start to download that file to the
> user. I am not sure if I am doing this right at all so help would be
> appreciated.
>
> Any ideas?
>
> tia.
>
> td.[/color]

TD,

The results of a call to mysql_query is not the data itself - it is a mysql
result set if the query works, or false if the query fails. You get the actual
data, one row at a time, by calling mysql_fetch_array or mysql_fetch_assoc.

In your example, you call mysql_fetch_assoc. So the value $row_dllink['dllink']
(aka $row_dllink[0] contains the results of the first query row (assuming the
query worked - ensure to check for failure!).

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
  #5  
Old July 17th, 2005, 03:15 PM
Peter van Schie
Guest
 
Posts: n/a

re: Can anyone help me with this problem please....?


toedipper wrote:
[color=blue]
> Tried the two suggestion but still no joy. The page just sits there and
> nothing happens. Am I correct in assuming that $dllink will correctly
> pick up the url from my db?
>
> Thanks,
>
> td.[/color]

Hi toedipper,

I didn't look at your database retrieval code the first time, but you're
right: $dllink will contain a resource and not a result row. $row_dllink
will if your query succeeds, so you'll have to use that variable instead:

<? echo '<META HTTP-EQUIV="refresh" CONTENT="6;
URL=http://' . $row_dllink["dllink"] . '">
'; ?>

P.S. you really should check the return values of the mysql_* calls.

--
http://www.phpforums.nl
Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can anyone help me with this code insirawali@gmail.com answers 33 October 1st, 2008 08:05 PM
Can anyone help me with this algorithm?(FIFO based inventory) doxtor answers 5 August 25th, 2008 04:10 AM
someone please help me with this..... rn5a@rediffmail.com answers 7 October 16th, 2006 12:35 PM
can anyone help me with this? Skysword answers 7 July 22nd, 2005 06:59 PM