LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   unexpected T_VARIABLE in php script (http://www.linuxquestions.org/questions/programming-9/unexpected-t_variable-in-php-script-321509/)

verbatim 05-08-2005 10:58 PM

unexpected T_VARIABLE in php script
 
I can't find the solution in my php editor.

The error starts at the 1st line of data :

Code:

$data["dbType"] = "mysql";
can someone tell me where my error is please?

Code:

<?php
  function post_it($datastream, $url) {

$url = preg_replace("@^http://@i", "", $url);
$host = substr($url, 0, strpos($url, "/"));
$uri = strstr($url, "/");
$reqbody = "";

      foreach($datastream as $key=>$val) {
          if (!is_empty($reqbody)) $reqbody.= "&";
      $reqbody.= $key."=".urlencode($val);
      }

$contentlength = strlen($reqbody);
    $reqheader =  "POST $uri HTTP/1.0\r\n".
                  "Host: $host\n". "User-Agent: PostIt\r\n".
    "Content-Type: application/x-www-form-urlencoded\r\n".
    "Content-Length: $contentlength\r\n\r\n".
    "$reqbody\r\n";

$socket = fsockopen($host, 80, $errno, $errstr);

if (!$socket) {
  $result["errno"] = $errno;
  $result["errstr"] = $errstr;
  return $result;
}

fputs($socket, $reqheader);

while (!feof($socket)) {
  $result[] = fgets($socket, 4096);
}

fclose($socket);

return $result;

}
?>

<? php

  $data["dbType"] = "mysql";
  $data["dbHost"] = "localhost";
  $data["dbUser"] = "mem";
  $data["dbPass"] = "letmein";
  $data["dbName"] = "mel";
  $data["dbPrefix"] = "mem_com_-_mel";
  $data["dbPersistent"] = "false";
 
  $result = post_it($data, " http://www.mem.com/userz/mel/admin.php?");

  if (isset($result["errno"])) {
    $errno = $result["errno"];
    $errstr = $result["errstr"];
    echo "<B>Error $errno</B> $errstr";
    exit;
  } else {

    for($i=0;$i< count($result); $i++) echo $result[$i];

  }

?>


enemorales 05-09-2005 12:21 PM

I don't have how to check it now, but: could it be the space between "<?" and "php" the problem? Is the line just before the one you mentioned...


All times are GMT -5. The time now is 02:39 AM.