Jump to content

Trouble inserting code into 'if/else' statement


Recommended Posts

I have this simple form that registers schools. This year I have decide to upgrade and include a feature that checks if the school is already registered or not based on the imputed name. Here is the code (that is the only way I know how):


mysql_connect("", "", "") or die(mysql_error( '' ));
mysql_select_db("") or die(mysql_error( '' ));

$query  = "SELECT * FROM School_Registrations WHERE School_Name= '$_POST[schoolName]' ";
$result = mysql_query($query);
if (mysql_numrows($result) > 0) {
while($row = mysql_fetch_array($result))

echo" error code here";} 

else {mysql_query("INSERT INTO `database`.`School_Registrations` (all the variables here);") 
or die(mysql_error( '' ));  

echo "Success Code";}


I am trying to incorporate this code somewhere into the 'else' statement but I have no luck. I am constantly getting some errors and when I fix one there is one more to take its place. I am lost. The last one I can not fix and I am not sure what it wants from me:


Fatal error: Call to undefined function getPage()


It works by itself without the if/else statement but not in the code listed above


$url = 'http://www.otherpage.com/page.php?';
$url .= 'email='.urlencode($_POST['email']);

$result2 = getPage('', $url, '', 15);

function getPage($proxy, $url, $header, $timeout) {
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_HEADER, $header);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_PROXY, $proxy);
    curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 1);
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
    curl_setopt($ch, CURLOPT_REFERER, 'http://azsef.org');
    curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0. Gecko/2009032609 Firefox/3.0.8');
    $result2['EXE'] = curl_exec($ch);
    $result2['INF'] = curl_getinfo($ch);
    $result2['ERR'] = curl_error($ch);
    return $result2;


Can you tell me why doesn't it work?


Link to comment
Share on other sites


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.