Skip to main content
April 8, 2010
Question

php script needed to generate unique page

  • April 8, 2010
  • 1 reply
  • 1599 views

Thank you for your understanding, I hope I am in the right place.

I am trying to generate about 30 unique pages to be visited by recipients of a piece of mail.

I am planning to use .htaccess to redirect the visitor to the unique, shortened url.

I cannot figure out how to get this to all work together. Please help

This topic has been closed for replies.

1 reply

April 9, 2010

I think if you're a bit more specific about what you're trying to do you will get more help... your description is very vague.

April 9, 2010

I am trying to implement a personalized url (purl) to print on a mail piece. I have created a mysql database and a form that places some unique information about the visitor using php.

I have successfully linked the page to the database and I believe the scripts for mailing responses will work, based on earlier successes. I did the binding to link the correct field from the database to the url. But now what?

My problem is that I have never generated a unique page and I cannot figure out how to do that. I am thinking that I need some piece of php script to create the dynamic page.

April 10, 2010

Hi Michael:

I made some progress. I did create a field called "index" that used incremental values. I changed that field to"id" to work with your suggestions.

Thanks to you, there is progress.

When I type the address with this at the end "seeds.php?id=4". I get the information from the first record only. It does not matter which id number I use, I still get only the first record information.

This is a link to a default page without the variable personalized information. http://www.deansmailing.com/seeds/

This is the new beginning script:

<?php require_once('../Connections/seeds.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
  $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;   
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

$id_Recordset1 = "-1";
if (isset($_GET['id'])) {
  $id_Recordset1 = (get_magic_quotes_gpc()) ? $_GET['id'] : addslashes($_GET['id']);
}
mysql_select_db($database_seeds, $seeds);
$query_Recordset1 = sprintf("SELECT * FROM seeds WHERE %s=%s", GetSQLValueString($id_Recordset1, "int"),GetSQLValueString($id_Recordset1, ""));
$Recordset1 = mysql_query($query_Recordset1, $seeds) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?>


Try a couple things...

First, it looks like you didn't use "colname" as your variable name when setting up the query. Go back and fix that. The NAME of the variable should be literally

colname

Then, on the line that says:

$query_Recordset1 = sprintf("SELECT * FROM seeds WHERE %s=%s", GetSQLValueString($id_Recordset1,

change the FIRST %s to id.  So it would read:

$query_Recordset1 = sprintf("SELECT * FROM seeds WHERE id=%s", GetSQLValueString($id_Recordset1,

On this line:

$query_Recordset1 = sprintf("SELECT * FROM seeds WHERE id=%s", GetSQLValueString($id_Recordset1, "int"),GetSQLValueString($id_Recordset1, ""));

delete the part past the close parenthesis after "int" all the way up to the last parenthisis... so it would read:

$query_Recordset1 = sprintf("SELECT * FROM seeds WHERE id=%s", GetSQLValueString($id_Recordset1, "int"));

Save this as a different page name, in case any of it breaks something you can just revert back to the old page and we can work from there. Maybe "index2.php"... then test it on that page "http://www.deansmailing.com/seeds/index2.php?id=3" Try these changes and see what happens. Let me know...