Welcome to the most active Linux Forum on the web.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 05-08-2005, 10:58 PM   #1
Registered: Apr 2005
Posts: 31

Rep: Reputation: 15
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 :

 $data["dbType"] = "mysql";
can someone tell me where my error is please?
  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". 

$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); 


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, ""); 

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

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


Old 05-09-2005, 12:21 PM   #2
Registered: Jul 2004
Location: Santiago, Chile
Distribution: Ubuntu
Posts: 410

Rep: Reputation: 31
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...


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
issues with mirc script accessing our php script dtra Linux - Software 2 07-02-2005 04:30 PM
PHP parse error unexpected '>' ldp Programming 2 03-04-2005 02:20 PM
PHP -- How to execute a shell script from PHP using FTP functions?? zoonalex Programming 3 07-29-2004 11:51 AM
converting shell script to php script ? ibro Linux - General 6 05-24-2004 05:19 AM
Gimp crashes suddenly LibGimp-WARNING **: script-fu: wire_read: unexpected EOF anorman Linux - Software 0 03-12-2004 12:53 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:04 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration