Jump to content

gabrielkolbe

Members
  • Posts

    41
  • Joined

  • Last visited

    Never

Posts posted by gabrielkolbe

  1. here'a an example ..hope it helps..

     

     

    $query = "UPDATE customer SET

    username= '" . $_POST['username'] . "',

    fname= '" . $first . "',

    lname= '" . $last . "',

    email= '" . $_POST['email'] . "',

    tel= '" . $_POST['tel'] . "',

    fax= '" . $_POST['fax'] . "',

    cell= '" . $_POST['cell'] . "',

    hnum= '" . $_POST['hnum'] . "',

    street= '" . $_POST['street'] . "',

    city= '" . $city . "',

    province= '" . $_POST['province'] . "' ,

    post_code= '" . $_POST['post_code'] . "'

    WHERE id = '".$_SESSION['userid']."'";

    $result = mysql_query($query) or die(mysql_error());

     

  2. hi, I am new to oo, created a simple email class which does not behave.

     

    When I run the class (below) so:

    if ($mail->sendMail($email, $_POST["subject"], $_POST["body"], $_POST["emailsender"])) {
    
    //to decode the above class it's (sendMail(to_emailaddress, subject, body, from_emailadress_or_name))
    
    $message="Success!!";
    	} else {
    $error= "There was an error... ";
    	}

     

    The email does go through BUT I get the error message the whole time, does anyone has any advice on this matter?

     

    <?PHP
    
    class email 
    {
    
    var $to;
    var $from;
    var $subject;
    var $body;
    
    function validateEmail($testemail){
    
    	$regexp ="^([_a-z0-9-]+)(\.[_a-z0-9-]+)*@([a-z0-9-]+)(\.[a-z0-9-]+)*(\.[a-z]{2,4})$";
    	if (eregi($regexp, $testemail)){return true;} else { return false;}
    
    	}
    
    
    
    function sendMail( $to, $subject, $body, $from ) {
    
    $headers = "MIME-Version: 1.0\r\n";
    $headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
    $headers .= "Content-Transfer-Encoding: 7bit\r\n";
    $headers = "From: {$from} \r\n";
    
    if ($this->validateEmail($to) == false)
    	{$error =  "email address {$to} is an invalid";} 
    		else { 
    				if ($this->validateEmail($from) == false)
    					{$error = "email address {$from} is an invalid";} 
    						else { 
    								$body=stripslashes($body);
    								$subject=stripslashes($subject);
    
    									if (mail ($to, $subject, $body, $headers))
    									{$message =  "Email {$subject} was send"; }
    
    									else { $error = "There was an error in sending an email to {$to}";
    									}
    									mail ('Admin@RightSite.co.za', $subject, $body, $headers);
    							}
    				}		
    
    print $message;
    print $error;
    
    	}	
    }
    
    ?>

  3. Hi, I have an uploading script that uploads a business card. It works in one place of my website but when I copy and paste the code onto another place the script runs, but does not add the new business card name on the database, the file get's copied to the server thou.

    Here is the code that works.....

    [code]
    if ($_POST['action'] == "add_bcard") {

    $status="";

    if (preg_match ("/jpg/i", $_FILES['bcard']['name'])) { $type="jpg"; $status="ok"; }
    if (preg_match ("/jpeg/i", $_FILES['bcard']['name'])) { $type="jpeg"; $status="ok"; }
    if (preg_match ("/gif/i", $_FILES['bcard']['name'])) { $type="gif"; $status="ok"; }
    if (preg_match ("/png/i", $_FILES['bcard']['name'])) { $type="png"; $status="ok"; }
    if($status=="ok"){

    $keychars = "abcdefghijklmnopqrstuvwxyz0123456789";
    $length = 3;
    $randkey = "";
    for ($i=0;$i<$length;$i++)  $randkey .= substr($keychars, rand(1, strlen($keychars) ), 1);

    $file = time().$randkey.".".$type;

    $uploadfile="../logos/".$file;

    if ((move_uploaded_file($_FILES['bcard']['tmp_name'], $uploadfile))or die("Couldn't copy the file!".$_FILES['bcard']['tmp_name'])){

    sv_image_small($uploadfile, $uploadfile, $_FILES['bcard']['type']);

    $sql="SELECT card FROM cardtable where userid = '".$_SESSION['userid']."'";
    $resultcheck = mysql_query($sql) or die("<b>ERROR:</b> " . mysql_error());
    if (mysql_num_rows($resultcheck) == 1) {
    $query="SELECT card FROM cardtable where userid = '".$_SESSION['userid']."'";
    $result = mysql_query($query) or die(mysql_error());
    while ($row = mysql_fetch_object($result)) {
    if($row->card <> ""){
    unlink("../logos/".$row->card);
    }
    }
    $sql="UPDATE cardtable set card = '$file' WHERE userid = '".$_SESSION['userid']."'";
    mysql_query($sql) or die(mysql_error());
    }
    }
    }
    }

    [/code]

    HERE is the code that does NOT work

    [code]
    if ($_POST['action'] == "add_agentbcard") {
    //$a_id is in comes from the form in the form of a hidden field - to make sure we get the variable..
    /// like so ///<input name="a_id" type="hidden" value="<?=$a_id?>">

    $a_id = $_POST['a_id'];
    $status="";

    if (preg_match ("/jpg/i", $_FILES['bcard']['name'])) { $type="jpg"; $status="ok"; }
    if (preg_match ("/jpeg/i", $_FILES['bcard']['name'])) { $type="jpeg"; $status="ok"; }
    if (preg_match ("/gif/i", $_FILES['bcard']['name'])) { $type="gif"; $status="ok"; }
    if (preg_match ("/png/i", $_FILES['bcard']['name'])) { $type="png"; $status="ok"; }
    if($status=="ok"){

    $keychars = "abcdefghijklmnopqrstuvwxyz0123456789";
    $length = 3;
    $randkey = "";
    for ($i=0;$i<$length;$i++)  $randkey .= substr($keychars, rand(1, strlen($keychars) ), 1);

    $file = time().$randkey.".".$type;

    $uploadfile="../logos/".$file;

    if ((move_uploaded_file($_FILES['bcard']['tmp_name'], $uploadfile))or die("Couldn't copy the file!".$_FILES['bcard']['tmp_name'])){

    sv_image_small($uploadfile, $uploadfile, $_FILES['bcard']['type']);
    $sql="SELECT cardFROM cardtable where userid = '".$a_id."'";
    $resultcheck = mysql_query($sql) or die("<b>ERROR:</b>with ".$sql." " . mysql_error());
    if (mysql_num_rows($resultcheck) == 1) {
    $query="SELECT card FROM cardtable where userid = ".$a_id."";
    $result = mysql_query($query) or die("<b>ERROR:</b>with ".$query." " . mysql_error());
    while ($row = mysql_fetch_object($result)) {
    if($row->card <> ""){
    unlink("../logos/".$row->card);
    }
    }
    $sql="UPDATE cardtable set card = ".$file." WHERE userid = ".$a_id."";
    mysql_query($sql) or die("<b>ERROR:</b>with ".$sql." " . mysql_error());
    }
    }
    }
    }[/code]

    I have at one piont copied the code from the one that works and replace only the
    ".$_SESSION['userid']."'";  with ".$a_id."";
    And still get a problem...
    Then i tried to hard code the ".$a_id."";  to something like '201';
    and still it does not work...I would really appreciate any help
    (please take no notice of table names and field names - these are fictional)
  4. I sounds easy and I am sure to some people it will be, but I am struggling and would appreciate some help.

    I have an array of email addresses and in the array I like to add an ';' character to each email address so that I can use the array in the mail to function - I want to send bulk emails to everyone on my email list. Any one any idea how to go about this, I would appreciate it!!

    Thanks

    This is my code at the moment when i echo out the list the ; character must be at the end of each email address..

    $mail = array();
    $query = "SELECT * FROM email_list WHERE hear = 'Yes'";
    $result = mysql_query($query) or die(mysql_error());
    while ($row = mysql_fetch_object($result)) {
    array_push ($mail, $row->email);
    }
    ?>

    <br><br><strong>Emails</strong><br>
    <? foreach ($mail as $ma => $key){

    echo $key; echo '<BR>'; }?>

    I know I can echo it out like so
    echo $key; echo ';'; echo '<BR>'; }?>

    But I need to it be part of an array otherwise I can not use it in the mailto fucntion

  5. I have a website where people can add and delete pictures. All worked fine, untill recently..out of the blue. I get error messages when trying to delete a picture..

    [quote]Warning: unlink(../logos/): Is a directory in /home/gabriel/public_html/include_cs/functions.php on line 1710[/quote]

    Here is the script..

    [code] $query="SELECT * FROM business_site2 WHERE user_id = '".$_SESSION['user_id']."'";
    $result = mysql_query($query) or die(mysql_error());
    while ($row = mysql_fetch_object($result)) { unlink("../logos/".$row->photo1); }code]

    I checked the php manual but can not see where the problem lays..anyone any ideas?[/code]
  6. Hi I get this error..

    [quote]Warning: unlink(../logos/): Is a directory in /home/public_html/include_cs/functions.php on line 1710

    Warning: Cannot modify header information - headers already sent by (output started at /home/public_html/include_cs/functions.php:1710) in /home/public_html/include_cs/functions.php on line 1714[/quote]

    [code] $query="SELECT * FROM site2 WHERE user_id = '".$_SESSION['user_id']."'";
    $result = mysql_query($query) or die(mysql_error());
    while ($row = mysql_fetch_object($result)) {unlink("../logos/".$row->logo.""); }

    $sql="UPDATE site2 set logo = '' WHERE user_id = '".$_SESSION['user_id']."'";
    mysql_query($sql) or die(mysql_error());
    header("Location: index.php?action=personalise_header");[/code]

    I know there is not suppose to be any code before the header that are printed , there are none!! this is a simple deletion script, it deletes a picture then get redirected.

    If somone has any advice to see if something IS printed please let me know..
    Regards

  7. Hi I hope there is someone who can help me with this one.

    I have to pass a from one document to another, because of the program, I have to pass it via a string. I know how to do this ... But then in the doc where the string is passed to I have to get the variable out again, and it is here where I have a problem.

    I passs it like so:

    $valuex= $_REQUEST['valuex'];

    // place array ($valuex) in a string to pass values to charts.swf

    $xstring = "";
    foreach($valuex AS $key => $vax) {
    $xstring =$xstring."%26valuex%5B%5D=$vax";
    }
    How do I get the value in the second document???

    I have tried this...
    $valuey = $_REQUEST["valuey"];
    $xstring = $_REQUEST["xstring"];
    $valuex = $_REQUEST["valuex"];
    (also tried placing a hidden field in the source doc)

    Would appreciate some help
  8. Hi, maybe someone can give me some advice where to begin. I want to add a feature on my website, where somone can search for a property via gps - or satnav, i know this will include lontitude and latitudes, i have an idea how these work. I would guess you take a map, divide into a grid with minutes and degrees, then in som way insert these values in to a database, then. When someone does a query the place gets queried agains a database? does any one has any ideas??
  9. Hi, i would appreciate if someone can just have a look at this and tell me where, I am going wrong.....I am trying to get a prop_ID from a table called right_prop_1, then use this ID to query a 'stats' table. The combine the info from both tables in rows that gets echoed out.

    Here is the code:

    thanks in advance.............

    [code]$query = "SELECT * FROM right_prop_1 WHERE user_id = '".$_SESSION['index']."'";
    $result = mysql_query($query) or die(mysql_error());
    if (mysql_num_rows($result) == 0) {
    ?>
            <tr bordercolor="#FFFFFF">
            <td class="menu_names" bgcolor= "<?=$row_color?>" colspan=5 >&nbsp;You have no visited Properties at this time</td>
            </tr>
    <? } else {

    $propid = $row->prop_ID;
    $type = $row->type;
    $suburb = $row->suburb;
    $price1=$row->price;
    $price = number_format($price1);



    $query = "SELECT * FROM stats  WHERE propid = '".$prop_ID."' order by propid asc limit ".$page.", 30";
    $result = mysql_query($query) or die(mysql_error());
    while ($row = mysql_fetch_object($result)) {
    $visited=mysql_num_rows($result);

    $row_color = ($row_count % 2) ? $color1 : $color2;
        ?>
        <tr bgstyle="color:#FFFFFF">
        <td width="20%" bgcolor= "<?=$row_color?>" class="menu_names">&nbsp;Refno:&nbsp;<span class="blacktahoma"><?=$prop_ID?></span></td>
        <td width="10%" bgcolor= "<?=$row_color?>" class="menu_names"><?=$type?></td>
        <td width="16%" bgcolor= "<?=$row_color?>" class="blacktahoma">R<?=$price?></td>
        <td width="20%" bgcolor= "<?=$row_color?>" class="menu_names"><?=$suburb?></td>
        <td width="17%" align="left" bgcolor= "<?=$row_color?>" class="menu_names">Viewed &nbsp;&nbsp;<?=$visited?></td>
        <td width="17%" bgcolor= "<?=$row_color?>" class="menu_names"><div align="right"><a href="index.php?action=detailstats&prop_ID=<?=$row->prop_ID?>">View details</a></div></td>
        </tr>
    <? $row_count++; } } ?>
    </table>[/code]
×
×
  • 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.