When I call the function below i get this error: Parse error: parse error, expecting `')'' in /home/wrjou27/public_html/testing/cpanel.php on line 2 Fatal error: Call to undefined function: addemail() in /home/wrjou27/public_html/testing/svc_emailreg.php on line 398 PHP: <? Function AddEmail (email, password, quota){ $fp = fsockopen("www.wrjournal.net", 2082, $errno, $errstr, 30); if (!$fp) { echo "$errstr ($errno)<br />\n"; } else { $out = "GET /frontend/Xskin/mail/doaddpop.html?email=" & $email & "&domain=wrjournal.net&password=" & $password & ""a=" & $quota & " HTTP/1.0\r\n"; $out .= "Authorization: Basic " & base64_encode ($CPANELUSER:$CPANELPASS) & "\r\n"; $out .= "Connection: Close\r\n\r\n"; fputs($fp, $out); while (!feof($fp)) { fgets($fp, 128); } fclose($fp); } ?>
is email, password, quota strings if so they need to be included in ' ' if they are variables they need a $ prefix.
hmm.. Okie Dokie. Ill look into that asap. Its been a while since i last coded php. I thought i didnt need the $ for the variables in the function. i should have just checked that anyway
I didnt think that was the problem. When i do that i get: Parse error: parse error in /home/wrjou27/public_html/testing/cpanel.php on line 9 Fatal error: Call to undefined function: addemail() in /home/wrjou27/public_html/testing/svc_emailreg.php on line 398 Maby you could look at the error then at the code, find a problem... (sry if you find me rude, im just a bit anoyed with this.) Are any of you really good with php?
Umm... ya well, you dont CALL in php. If you think you do, please explain more. Even with the } I still get an error. Prahaps someone who knows what there doing could study it? PHP: <? Function AddEmail ($email, $password, $quota){ $fp = fsockopen("www.wrjournal.net", 2082, $errno, $errstr, 30); if (!$fp) { echo "$errstr ($errno)<br />\n"; } else { $out = "GET /frontend/Xskin/mail/doaddpop.html?email=" & $email & "&domain=wrjournal.net&password=" & $password & ""a=" & $quota & " HTTP/1.0\r\n"; $out .= "Authorization: Basic " & base64_encode ($CPANELUSER:$CPANELPASS) & "\r\n"; $out .= "Connection: Close\r\n\r\n"; fputs($fp, $out); while (!feof($fp)) { fgets($fp, 128); } fclose($fp); } } ?>
I would replace "&" with "." and possibly a "\r\n" before the HTTP/1.0? Oh, and change base64_encode($var:$var) to base64_encode($var . ":" . $var) Code: <?php Function AddEmail ($email, $password, $quota){ $fp = fsockopen("www.wrjournal.net", 2082, $errno, $errstr, 30); if (!$fp) { echo "$errstr ($errno)<br />\n"; } else { $out = "GET /frontend/Xskin/mail/doaddpop.html?email=" . $email . "&domain=wrjournal.net&password=" . $password . ""a=" . $quota . "\r\nHTTP/1.0\r\n"; $out .= "Authorization: Basic " . base64_encode ($CPANELUSER . ":" . $CPANELPASS) . "\r\n"; $out .= "Connection: Close\r\n\r\n"; fputs($fp, $out); while (!feof($fp)) { fgets($fp, 128); } fclose($fp); } } ?> I'm not as familiar with all of the fsockopen stuff as I want to be, but the only thing I noticed is the use of "&" to concantenate strings. I could be very wrong in this, but if I were to write: <?php echo "this" & " this"; ?> it would echo out: `ha And the $out string would have looked similar to: Code: "GET /frontend/Xskin/mail/doaddpop.html?email=username&domain=wrjournal.net&password=pass"a=1234 HTTP/1.0 Authorization: Basic {base64 not processed} Connection: Close "; which makes me think the value of $_GET['quota'] might be "1234 HTTP/1.0" but once again, I don't know much about fsockopen. The new way should make it look more like: Code: "GET /frontend/Xskin/mail/doaddpop.html?email=username&domain=wrjournal.net&password=password"a=1234 HTTP/1.0 Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ= Connection: Close "; (and if you base64_Decode(dXNlcm5hbWU6cGFzc3dvcmQ=) you would get "username:password") Not sure if this helps any, but my script would just stop running at the base64_encode, and would give garbled data once I fixed that because of "&". Oh, and all this asking for help and not really knowing what your doing but trying anyway, is exactly how I learned PHP, so keep up the good work! (not having any errors is a sign of not trying )
well, thats a lot to read. but, i know all my HTTP prot code is correct, iv tested that all, then put it in the location i needed, then added vars. so i know, i dont have to change any. But, as you pointed out the & is probably a big problem. I havent coded php in a while. Im used to the & forgot i should use . , ill try that. thx
Thx OneSeventeen! Final Code: PHP: <? Function AddEmail ($email, $password, $quota){ $fp = fsockopen("www.wrjournal.net", 2082, $errno, $errstr, 30); if (!$fp) { echo "$errstr ($errno)<br />\n"; } else { $out = "GET /frontend/Xskin/mail/doaddpop.html?email=$email&domain=wrjournal.net&password=$password"a=$quota HTTP/1.0\r\n"; $out .= "Authorization: Basic " . base64_encode ($CPANELUSER . ":" . $CPANELPASS) . "\r\n"; $out .= "Connection: Close\r\n\r\n"; fputs($fp, $out); while (!feof($fp)) { fgets($fp, 128); } fclose($fp); } } ?>