Link problem

Her kan du få hjælp og stille spørgsmål til PHP!
Besvar
Flimmer
Begynder
Indlæg:4
Tilmeldt:21. dec 2012, 08:23
Link problem

Indlæg af Flimmer » 21. dec 2012, 08:55

Pænt Goddag alle
Jeg har lavet en side som søger et par felter i DB "find.php" som jeg så includerer i "start.php" som indholder en række
switch statement i en content <DIV> i midten af siden.
Nu er mit problem at min $var ikke vil op browser adr.
jeg får kun
http://www.minside.dk/start.php?action=find&search=(her mangler min $var)
Skal lige siges at hvis jeg selv sætter min $var ind i browser adr. virker det uden problemer:
http://www.minside.dk/start.php?action=find&search=bmw

Det meste af find.php

Kode: Vælg alt

 
<?php

// Get the search variable from URL
$action = $_GET['action'];
$var = @$_GET['search'];

[b]Et lille udvalg af afprøvet links:[/b]
$self = "http://www.etaten.dk/start.php?action=find&search=$var";
//$self = "http://www.etaten.dk/start.php?action=find&search=".$var."";
//$self = "http://www.etaten.dk/start.php?action=find&search='$var'";
//$self = "http://www.etaten.dk/start.php?action=find&search=".$_SERVER['var']."";

//trim whitespace from the stored variable  
$trimmed = trim($var);

// check for an empty string and display a message.
if ($trimmed == "")
  {
  echo "<p>Please enter a search...</p>";  
  echo "<form action=\"$self\" method=\"POST\">        
		<input type=\"text\" name=\"search\" />        
		<br />
		<input type=\"submit\" value=\"Search\" />    
		</form>";
  exit;
  }

// check for a search parameter
if (!isset($var))
  {
  echo "<p>We dont seem to have a search parameter!</p>";
  exit;
  }
  
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $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;
}
}

$currentPage = $_SERVER["PHP_SELF"];

$maxRows = 9;
$pageNum = 0;

Det resterende code er paginering

Senest rettet af Flimmer 22. dec 2012, 18:46, rettet i alt 3 gange.

Brugeravatar
scootergrisen
Moderator
Moderator
Indlæg:709
Tilmeldt:21. jun 2012, 23:40
Kontakt:

Re: switch statement driller

Indlæg af scootergrisen » 21. dec 2012, 16:42

Vi kan ikke se hvad $action indeholder.

Besvar