Jump to content

joel24

Members
  • Posts

    760
  • Joined

  • Last visited

Posts posted by joel24

  1. sorry I've never have to do this before - is your fsockopen acquiring a connection?

    someone else may have successfully achieved this before and be able to help...

    $fp = fsockopen("www.example.com", 80, $errno, $errstr, 30);
    if (!$fp) {
        echo "$errstr ($errno)<br />\n";
    } else {
        //create array of data to be posted
        //$post_data['firstName'] = 'Name';
        $post_data['item_name'] = '12345';
         
        //traverse array and prepare data for posting (key1=value1)
        foreach ( $post_data as $key => $value) {
            $post_items[] = $key . '=' . $value;
        }
         
        //create the final string to be posted using implode()
        $post_string = implode ('&', $post_items);
         
        //we also need to add a question mark at the beginning of the string
        $post_string = '?' . $post_string;
         
        //we are going to need the length of the data string
        $data_length = strlen($post_string);
        //sending the data
        fputs($connection, "POST  /i.php  HTTP/1.1\r\n");
        fputs($connection, "Host:  www.example.com \r\n");
        fputs($connection,
            "Content-Type: application/x-www-form-urlencoded\r\n");
        fputs($connection, "Content-Length: $data_length\r\n");
        fputs($connection, "Connection: close\r\n\r\n");
        fputs($connection, $post_string);
         
        //closing the connection
        fclose($connection);
    }
    

  2. you need to start the session before checking values are set.

    <?php
    session_start();
    if(isset($_SESSION["isAuthenticated"])) {
            print "YOU ARE ACCESSING SECURE DATA!"
    
    else {
    print "You must be registered or logged in to continue.";
    print "<hr />";
    print "<a href='xmlShredderRegister.php'>Create account</a> <br />";
    print "<a href='xmlShredderLogin.php'>Login</a>";
    }
    ?>

  3. you're calling the mysql_query twice...

    
        $sql = ("SELECT (fee + upgrade + tax) AS theTotal, * FROM Teamregister WHERE pkSoloregisterID=$pkSoloregisterID");
        $result = mysql_query($sql);
        $myrow = mysql_fetch_array($result);
    
    echo $myrow['theTotal'];
    

     

  4. send an email for each iteration of the while loop...

    this will take up many more resources than if you had used CC or BCC, someone else may know a better solution?

    another option to deter spam filtering - send it via gmail's SMTP (if you've signed up to use google mail with your domain)

    $sql=@mysql_query("SELECT name, email FROM people WHERE event='christmas'"); #whichever event
    while ($row=mysql_fetch_assoc($sql)) {
    mail($row['email'],'the subject','the message');
    }
    

  5. $sql=@mysql_query("SELECT * FROM etc etc");
    
    $retail=0;
    $sales=0;
    
    while ($row=mysql_fetch_assoc($sql)) {
    if ($row['retail_sales.amount'] > $row['online_sales.amount']) {
    $retail++;
    } else {
    $sales++;
    }
    }
    
    echo "$retail - $sales";
    

  6. not entirely sure exactly what you're after...?

    $radio1=(isset($_POST['radioButton1']) )?$_POST['radioButton1']:'';
    $radio2=(isset($_POST['radioButton2']) )?$_POST['radioButton2']:'';
    $radio3=(isset($_POST['radioButton3']) )?$_POST['radioButton3']:'';
    
    $sql=@mysql_query("UPDATE table SET
    radio1='$radio1',
    radio2='$radio2',
    radio3='$radio3' 
    WHERE id='$id'");
    

  7. i think you should go with the pageviews / history table - all three of us seem to agree on the one solution;

    and don't worry about slowing the database with too many records - you can set up some cronjobs later to delete any records over a certain amount for each user.

    pageViews; pageView (auto_increment - primary key)' date=' page, datetime, userid[/quote']

    I would create a table with 3 columns:

    id, user_id, page

    table named "History" with the 3 fields of id' date=' user_id and page[/quote']
  8. it will be much easier to pop up a <div> element with the message rather than a new window.

    Have a look into ajax - I would submit the form with ajax to the save_to_favourites.php and then have the response message displayed in a popup div.

     

    If you want to use a new window (some browsers may block this) then you can grey out the current screen using just the popup div and then you'll have to alert the parent window to hide that grey out once the actions are complete.

  9. you need to use javascript to do this. have a look at the jQuery framework and this tutorial

     

    to grey it out, you need to have a div that takes up the entire screen (100% x 100%) positioned on top of the main document but behind the popup (using z-index). Then when a user clicks on 'save to favourites' you set the script to popup the message and the greyed out div. jQueryUI's Shadow has a pleasant shadow/greyed div.

     

    *edit* or google for some javascript popup tutorials, though the jQuery framework will make life a lot easier.

  10. not exactly sure what you're after... or what value you're trying to assign...  current value?

    $doc=new DOMDocument();
    mysql_connect("localhost","root");
    mysql_select_db("xmlDB");
    
    $edges=mysql_query("SELECT * FROM edge");
    while($row=mysql_fetch_assoc($edges)) {
    if($row['flag']=='val') {
    	$curValue=mysql_query("SELECT val FROM value,edge WHERE val.edge_id=edge.edge_id");
    	if($curRowIsAttribute=mysql_query("SELECT is_Attribute FROM value,edge WHERE value.is_Attribute='Y' AND value.edge_id=edge.edge_id")) {
    		//create attribute node
    $currentValue=mysql_result($curValue,0); //will retrieve val from the $curValue sql query - you can use mysql_fetch_assoc etc which is more efficient though in this situation you can play around with it... 
    		$newAttr=$dom->createAttribute($currentValue);//HELP HERE PLEASE THEN I SHOULD BE ABLE TO COMPLETE NEXT TWO LINES BELOW!
    
    		//set attribute value
    		...
    
    		//append attribute to current element
    		...	
    
    		}//END IF
    	}//END IF
    }//END BIG WHILE 
    

  11. i would setup a relational database-

    users; userid (auto_increment - primary key), email, joined, country

    pageViews; pageView (auto_increment - primary key), page, datetime, userid

     

    link users table to the pageViews table and insert the pageViews into the pageViews table - with added information such as datetime so you know when they viewed that page.

     

    If you want to limit this to 5, then you can run a

    $check = @mysql_query("SELECT pageView FROM pageViews WHERE user_id='{$_SESSION['user_id']}'");
    if (mysql_num_rows($check) >= 5) {
    @mysql_query("DELETE FROM pageViews ORDER BY `datetime` LIMIT 1");
    }
    
    //insert page view
    
    

     

    I would be inclined to store all the pageviews and not commit to deleting, also I've assumed you have the user id kept in the session somewhere? if not, you can change the session value to a $_GET value or however you determine the userID you're searching for.

    I would be

  12. you're trying to use a composite primary key which is fine and unique. i.e. your primary key would be (quizid, answerid)

    google it or have a quick read here

     

    as for columns or fields, I hear both terms used frequently - i'm sure someone else will have some input into this question.

×
×
  • 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.