Jump to content

Help with send function


zack45668

Recommended Posts

for some reason, this script creates a Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /home/gnzp/public_html/bot/ak_bot.php on line 296

the fputs line is 296. Can anyone help me?

 

##--------------------------------------------
##SEND FUNCTION
##Sends any data to the server
##--------------------------------------------
function send($data){
echo "<strong><font color="#FF0000">".$data."</font></strong><br>";
fputs($this->fp, $data."\r\n");
} 

 

-Zack

Link to comment
https://forums.phpfreaks.com/topic/100969-help-with-send-function/
Share on other sites

Try this:

 

<?php
##--------------------------------------------
##SEND FUNCTION
##Sends any data to the server
##--------------------------------------------
function send($data){
echo "<strong><font color=\"#FF0000\">".$data."</font></strong><br>";
fputs($this->fp, $data."\r\n");
} 
?>

Thanks that worked perfectly. Now i need help with this:

 

##--------------------------------------------
##GOOGLE FUNCTION
##Controls the google search function
##--------------------------------------------
function google(){
if($this->data[message_action_text]){
$address = "http://www.google.com/search?hl=en&ie=UTF-8&oe=UTF-8&q=".$this->data[message_action_text];
$gfp = fopen($address, "r");
while (!feof($gfp) AND $STOP<>'TRUE'){
$gdata .= fgets($gfp, 1024);
if(strstr($gdata, "<font color=#008000>")){
$pos = strpos($gdata, "<font color=#008000>");
$gdata = substr($gdata, $pos+20);
$pos = strpos($gdata, " - ");
$gdata = substr($gdata, 0, $pos);
$STOP = 'TRUE';
}
}
fclose($gfp);

if($STOP<>'TRUE' OR $gdata == ""){
$this->send("PRIVMSG ".$this->data[sent_to]." :".$this->data[from].": There were no results for: "".$this->data[message_action_text_plain].""");
}else{
if(!ereg("^(http|https)\://[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(/\S*)?/?([a-zA-Z0-9\-\._\?\,''/\\\+&%\$#\=~])*$", $gdata)){
$gdata = "http://".$gdata;
}
$this->send("PRIVMSG ".$this->data[sent_to]." :".$this->data[from].": Result For: "".$this->data[message_action_text_plain]."" - $gdata");
}
}else{
$this->send("NOTICE ".$this->data[from]." :Usage: !google <search phrase/word>");
}
}

 

It gives me the error of "Parse error: syntax error, unexpected '"' in /home/gnzp/public_html/bot/ak_bot.php on line 473"

 

This is line 473:

$this->send("PRIVMSG ".$this->data[sent_to]." :".$this->data[from].": There were no results for: "".$this->data[message_action_text_plain].""");

 

-Zack

You must escape double quotes that you wish to be part of a string. The escape character in PHP is the \ (backslash).

 

<?php echo "He turned around, \"It is time you get to bed!\". He stood there waiting for an answer."?>

 

Meanwhile, since you are not parsing anything inside those strings, you should instead use single quotes and get used to them as a means to express strings in PHP. You only want to use double quotes when you mean to parse their contents.

 

<?php
$myvar = 2;
echo "You are right. It's past {$myvar}am";
?>

 

Finally check the PHP manual for other special characters that need to be escaped.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.