skip to Main Content

I have this code to create a new OrdID if no value for this variable exists:

If ($OrdID=="")
{
$con = mysql_connect("localhost","xxx","xxx");
mysql_select_db("xxx_Order", $con);
$query=mysql_query("Select Max(OrdID) FROM `Order`");
while($row=mysql_fetch_array($query))
{
$OrdID= $row[0] + 1;
}
$sql = "INSERT INTO `xxx_Order`.`Order` (`OrdID`) VALUES ($OrdID);"; 
if (!mysql_query($sql,$con))
  {
  die('Error: ' . mysql_error());
  }
mysql_close($con);
}

Of course before the above code I have(and I tried to place below code first line of my php file, in the head section and in the body section and also tried $_GET instead of $_REQUEST:

$OrdID=$_REQUEST["OrdID"];

But when I copy/paste following link in the browser the variable/value doesn’t get picked up and above code creates a new OrdID:
example.com/test.htm?OrdID=304819

What am I missing? Thanks

Tried $_GET instead of $_REQUEST. Placed code at different sections

Update: Actually I think I know the problem…its my htaccess redirect of:

RewriteRule link--(.*)--(.*)--(.*)--(.*)--(.*).htm$ example.php?Vendor=$1&Maincategory=$2&Source=$3&Pos=$4&Search=$5

Why I think it is the above redirect is because no matter what I add at the end of example.com/test.htm it will always redirect to:

example.php?Vendor=$1&Maincategory=$2&Source=$3&Pos=$4&Search=$5

2

Answers


  1. Chosen as BEST ANSWER

    Fully understand if this gets downvoted as a very poor solution.

    I just can't work out how to pass on the %{QUERY_STRING} so my poor but working solution is: Added another redirect:

    RewriteRule link--(.*)--(.*)--(.*)--(.*)--(.*)--(.*)--(.*).htm$ example.php?Vendor=$1&Maincategory=$2&Source=$3&Pos=$4&Search=$5&OrdID=$6&UserID=$7
    

    Thanks


  2. RewriteEngine On
    RewriteRule ^link–([^/])–([^/])–([^/])–([^/])–([^/]*).htm$ example.php?Vendor=$1&Maincategory=$2&Source=$3&Pos=$4&Search=$5 [L]

    Please try this

    $OrdID=$_GET["OrdID"];
    
    If (!empty($OrdID))
    {
    $con = mysql_connect("localhost","xxx","xxx");
    mysql_select_db("xxx_Order", $con);
    $query=mysql_query("Select Max(OrdID) FROM `Order`");
    while($row=mysql_fetch_array($query))
    {
    $OrdID= $row[0] + 1;
    }
    $sql = "INSERT INTO `xxx_Order`.`Order` (`OrdID`) VALUES ($OrdID);"; 
    if (!mysql_query($sql,$con))
      {
      die('Error: ' . mysql_error());
      }
    mysql_close($con);
    }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search