Hi

Im having a go at this, but not good on the php thing, thats why im hoping you can help.

I am trying to set up a jump script from one I have used for 1 or 2 urls, now I have a database of around 500000 lines, each one has an id field and a link field to jump to. I can send the info for the function but cant get it to add the field from the database. This is the code I have got so far.

<?php
$con = mysql_connect("localhost","blar","blar");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("blar", $con);
$m = $_GET['m'];
ob_start();
$query = "SELECT `ID`, 'Link' FROM TABLE where `ID` ='$m' LIMIT 1"; 
$result = mysql_query($query) or die(mysql_error());
if ($m == "['ID']"){$link = "['Link']";}
   echo "sending to page now";
header("Location: $link");
ob_flush();
die();
?>

the page is sending the m=id and the page "sending to page now comes" up but no redirect occurs?
Hope someone can help
Thanks in advance

After line 12 you need to $row = mysql_fetch_array($result); If $row is false then no record is found, else you can use $row['Link']. Note that you cannot output anything if you want to use header. (Remove line 17.)

Hi

Thanks for you quick reply, I have added that line and added the $row yet I get this error
unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING

Can you help?

Not without your changed code. Probably a missing quote or semi-colon.

<?php
$con = mysql_connect("localhost","blar","blar");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("blar", $con);
$m = $_GET['m'];
ob_start();
$query = "SELECT `ID`, 'Link' FROM TABLE where `ID` ='$m' LIMIT 1"; 
$result = mysql_query($query) or die(mysql_error());
$row = mysql_fetch_array($result);
if ($m == "$row['ID']"){$link = "$row['Link']";}
   echo "sending you to new page";
header("Location: $link");
ob_flush();
?>

Line 11, single quotes around Link should be backticks. Line 14, remove all double quotes. But what line do you get your error? Always paste the full error message with the problematic code snippet.

IT works perfectly now :)
Thank you so much fo your help

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.