Jump to content

Fenhopi

Members
  • Posts

    121
  • Joined

  • Last visited

    Never

Posts posted by Fenhopi

  1. Okay, so I have this site mydomain.com. When the user logs on there I want the user to be able to go to forum.mydomain.com without getting logged out. So I've googled this for days, and here's what I've found out:

    I don't have access to my hosts php.ini file, so I can't change anything there.

    I've put

    ini_set("session.cookie_domain", ".mydomain.com");

    on top of my session.php file.

    I've edited the .htaccess in both the forum folder and my root folder to

    php_value session.cookie_domain ".mydomain.com"

    .

     

    Still, after all this; it's totally random wether the session works on both or not. Sometimes it works, others it doesn't. I think perhaps it usually stops working after I've edited on some files on my site.. but I just have no idea what's wrong..

    All help would be appriciated!

  2. Thanks for replying! Okay, I tried this, with no success..

    <?
    include("include/session.php");
    ?>
    <html>
    <head>
    <title>Preload Image Page</title>
    
    
    <script language="JavaScript1.1">
    <!-- begin hiding
    
    /*
    Preload Image With Update Bar Script (By Marcin Wojtowicz [one_spook@hotmail.com])
    Submitted to and permission granted to Dynamicdrive.com to feature script in it's archive
    For full source code to this script and 100's more, visit http://dynamicdrive.com
    */
    
    // You may modify the following:
    var locationAfterPreload = "http://dynamicdrive.com" // URL of the page after preload finishes
    var lengthOfPreloadBar = 150 // Length of preload bar (in pixels)
    var heightOfPreloadBar = 15 // Height of preload bar (in pixels)
    // Put the URLs of images that you want to preload below (as many as you want)
    	<?php
    $Get_pictures = "SELECT bilde FROM beis";
    $Connect_bilde = $database->query($Get_pictures);
    while($rad = mysql_fetch_array($Connect_bilde)){
    	$my_array[] = $rad['bilde'];
    }
    $nummer = count($my_array);
    echo "var yourImages = new Array(" . $nummer . ");";
    $stab = "0";
    while($stab < $nummer){
    	echo " yourImages[".$stab."]=".$my_array[$stab]."\n"; 
    	$stab++;
    }
    
    ?>
    
    // Do not modify anything beyond this point!
    if (document.images) {
    var dots = new Array() 
    dots[0] = new Image(1,1)
    dots[0].src = "images/black.gif" // default preloadbar color (note: You can substitute it with your image, but it has to be 1x1 size)
    dots[1] = new Image(1,1)
    dots[1].src = "images/blue.gif" // color of bar as preloading progresses (same note as above)
    var preImages = new Array(),coverage = Math.floor(lengthOfPreloadBar/yourImages.length),currCount = 0
    var loaded = new Array(),i,covered,timerID
    var leftOverWidth = lengthOfPreloadBar%coverage
    }
    function loadImages() { 
    for (i = 0; i < yourImages.length; i++) { 
    	preImages[i] = new Image()
    	preImages[i].src = yourImages[i]
    }
    for (i = 0; i < preImages.length; i++) { 
    	loaded[i] = false
    }
    checkLoad()
    }
    function checkLoad() {
    if (currCount == preImages.length) { 
    	location.replace(locationAfterPreload)
    	return
    }
    for (i = 0; i <= preImages.length; i++) {
    	if (loaded[i] == false && preImages[i].complete) {
    		loaded[i] = true
    		eval("document.img" + currCount + ".src=dots[1].src")
    		currCount++
    	}
    }
    timerID = setTimeout("checkLoad()",10) 
    }
    // end hiding -->
    </script>
    
    </head>
    
    <body bgcolor="#FFFFFF">
    
    <center>
    <font size="4">Please be patient while some images<br>
    are being preloaded...</font><p>
    0%
    <script language="JavaScript1.1">
    <!-- begin hiding
    // It is recommended that you put a link to the target URL just in case if the visitor wants to skip preloading
    // for some reason, or his browser doesn't support JavaScript image object.
    if (document.images) {
    var preloadBar = ''
    for (i = 0; i < yourImages.length-1; i++) {
    	preloadBar += '<img src="' + dots[0].src + '" width="' + coverage + '" height="' + heightOfPreloadBar + '" name="img' + i + '" align="absmiddle">'
    }
    preloadBar += '<img src="' + dots[0].src + '" width="' + (leftOverWidth+coverage) + '" height="' + heightOfPreloadBar + '" name="img' + (yourImages.length-1) + '" align="absmiddle">'
    document.write(preloadBar)
    loadImages()
    }
    document.write('<p><small><a href="javascript:window.location=locationAfterPreload">Skip Preloading</a>  |  <a href="http://dynamicdrive.com/">Script Credits</a></small></p>')
    // end hiding -->
    </script>
    </center>
    
    </body>
    </html>
    

  3. Hi, I retrieve the pictures I want to display through a php loop that stores them in an array. What I want to do is to get those array values to get recognized by my js preloading script. Any tips how I'd do that?

    Here's my code (The relevant part is at the top):

    <html>
    <head>
    <title>Preload Image Page</title>
    
    <?php
    $Get_pictures = "SELECT bilde FROM beis";
    $Connect_bilde = $database->query($Get_pictures);
    while($rad = mysql_fetch_array($Connect_bilde)){
    $my_array[] = $rad['bilde'];
    }
    ?>
    <script language="JavaScript1.1">
    <!-- begin hiding
    
    /*
    Preload Image With Update Bar Script (By Marcin Wojtowicz [one_spook@hotmail.com])
    Submitted to and permission granted to Dynamicdrive.com to feature script in it's archive
    For full source code to this script and 100's more, visit http://dynamicdrive.com
    */
    
    // You may modify the following:
    var locationAfterPreload = "http://dynamicdrive.com" // URL of the page after preload finishes
    var lengthOfPreloadBar = 150 // Length of preload bar (in pixels)
    var heightOfPreloadBar = 15 // Height of preload bar (in pixels)
    // Put the URLs of images that you want to preload below (as many as you want)
    var yourImages = new Array("<? echo $my_array; ?>","http://yourdomain.com/test2.gif")
    
    // Do not modify anything beyond this point!
    if (document.images) {
    var dots = new Array() 
    dots[0] = new Image(1,1)
    dots[0].src = "black.gif" // default preloadbar color (note: You can substitute it with your image, but it has to be 1x1 size)
    dots[1] = new Image(1,1)
    dots[1].src = "blue.gif" // color of bar as preloading progresses (same note as above)
    var preImages = new Array(),coverage = Math.floor(lengthOfPreloadBar/yourImages.length),currCount = 0
    var loaded = new Array(),i,covered,timerID
    var leftOverWidth = lengthOfPreloadBar%coverage
    }
    function loadImages() { 
    for (i = 0; i < yourImages.length; i++) { 
    	preImages[i] = new Image()
    	preImages[i].src = yourImages[i]
    }
    for (i = 0; i < preImages.length; i++) { 
    	loaded[i] = false
    }
    checkLoad()
    }
    function checkLoad() {
    if (currCount == preImages.length) { 
    	location.replace(locationAfterPreload)
    	return
    }
    for (i = 0; i <= preImages.length; i++) {
    	if (loaded[i] == false && preImages[i].complete) {
    		loaded[i] = true
    		eval("document.img" + currCount + ".src=dots[1].src")
    		currCount++
    	}
    }
    timerID = setTimeout("checkLoad()",10) 
    }
    // end hiding -->
    </script>
    
    </head>
    
    <body bgcolor="#FFFFFF">
    
    <center>
    <font size="4">Please be patient while some images<br>
    are being preloaded...</font><p>
    0%
    <script language="JavaScript1.1">
    <!-- begin hiding
    // It is recommended that you put a link to the target URL just in case if the visitor wants to skip preloading
    // for some reason, or his browser doesn't support JavaScript image object.
    if (document.images) {
    var preloadBar = ''
    for (i = 0; i < yourImages.length-1; i++) {
    	preloadBar += '<img src="' + dots[0].src + '" width="' + coverage + '" height="' + heightOfPreloadBar + '" name="img' + i + '" align="absmiddle">'
    }
    preloadBar += '<img src="' + dots[0].src + '" width="' + (leftOverWidth+coverage) + '" height="' + heightOfPreloadBar + '" name="img' + (yourImages.length-1) + '" align="absmiddle">'
    document.write(preloadBar)
    loadImages()
    }
    document.write('<p><small><a href="javascript:window.location=locationAfterPreload">Skip Preloading</a>  |  <a href="http://dynamicdrive.com/">Script Credits</a></small></p>')
    // end hiding -->
    </script>
    </center>
    
    </body>
    </html>
    

  4. Hi, I'm aware that there are some difficulties with using javascript in php loops because of the client side and server side work that's being done.

    Anyways, here's what I got:

    Code:

    
    function alertBox() {
    document.sendform.to2.value = document.getElementById('test3').value;  
    document.sendform.to.value = document.getElementById('test4').value;
    e.style.display="none";  
    }
    while ($row = mysql_fetch_array($getRecord)) {
    	$TheirProfilePicture = $row['profilepicture'];
    	$mysock = getimagesize("http://face2blog.comlu.com/images/uploads/$TheirProfilePicture?time=time()");?>
    	<li><a href="#" onClick="alertBox();" id="test"><img src="http://face2blog.comlu.com/images/uploads/<? echo $TheirProfilePicture ?>?time=<?php echo time(); ?>" <? echo imageResize($mysock[0], $mysock[1], 45); ?> /> <font color="grey" size="3"><?php echo $row['firstname']; ?> <?php echo $row['lastname']; ?></font><input type="hidden" id="test3" value="<?php echo $row['firstname']; ?> <?php echo $row['lastname']; ?>"><input type="hidden" id="test4" value="<?php echo $row['username']; ?>"></a></li>
    
    <?php } 

     

    Please ignore the lach of script tags, I'm just pasting in what's relevant.

     

    This is the code of my autosuggest search thingy. When a user clicks one of the suggestions I'd like alertbox(); to get the info of the one I picked, not the last result that was looped.

    Is there a way or a trick that I could do to make this work with ajax?

     

    Thank you in advance!

  5. Hi, I'm aware that there are some difficulties with using javascript in php loops because of the client side and server side work that's being done.

    Anyways, here's what I got:

    function alertBox() {
    document.sendform.to2.value = document.getElementById('test3').value;  
    document.sendform.to.value = document.getElementById('test4').value;
    e.style.display="none";  
    }
    while ($row = mysql_fetch_array($getRecord)) {
    	$TheirProfilePicture = $row['profilepicture'];
    	$mysock = getimagesize("http://face2blog.comlu.com/images/uploads/$TheirProfilePicture?time=time()");?>
    	<li><a href="#" onClick="alertBox();" id="test"><img src="http://face2blog.comlu.com/images/uploads/<? echo $TheirProfilePicture ?>?time=<?php echo time(); ?>" <? echo imageResize($mysock[0], $mysock[1], 45); ?> /> <font color="grey" size="3"><?php echo $row['firstname']; ?> <?php echo $row['lastname']; ?></font><input type="hidden" id="test3" value="<?php echo $row['firstname']; ?> <?php echo $row['lastname']; ?>"><input type="hidden" id="test4" value="<?php echo $row['username']; ?>"></a></li>
    
    <?php } 
    

    Please ignore the lach of script tags, I'm just pasting in what's relevant.

     

    This is the code of my autosuggest search thingy. When a user clicks one of the suggestions I'd like alertbox(); to get the info of the one I picked, not the last result that was looped.

    Is there a way or a trick that I could do to make this work?

     

    Thank you in advance!

  6. I want my query to return the values where person='$username' and status=0 from one table, and the same in another table.

    Here's what I got:

    $GetStatus = "SELECT comments.status, friends.status FROM comments, friends WHERE (comments.person='$username' AND comments.status='0') OR (friends.user2='$username' AND friends.status='0')";

     

    However it just returns values from different rows where the status is different than 0..

  7. Hi, I have this piece of code:

    function GetAlerts(){
    $username = mysql_real_escape_string($_SESSION['username']);
    $GetStatus = "SELECT comments.status, friends.status FROM comments, friends WHERE comments.person='$username' AND friends.user2='$username'";
    $Connect = $database->query($GetStatus);
    $NumberRows = mysql_num_rows($Connect);
    return $NumberRows;
    }
    

    When I call the function I get:

    Fatal error: Call to a member function query() on a non-object

    And it points to the $GetStatus line.

    However, if I just use the code like this:

    $username = mysql_real_escape_string($_SESSION['username']);
    $GetStatus = "SELECT comments.status, friends.status FROM comments, friends WHERE comments.person='$username' AND friends.user2='$username'";
    $Connect = $database->query($GetStatus);
    $NumberRows = mysql_num_rows($Connect);
            echo $NumberRows;
    

    it works perfectly..

     

    Any ideas?

     

    Thanks in advance.

  8. Hi, I'm building a blog, and I want the user to be able to add images to their entry.

    But I can't quite figure out how to this without risking injections. I see that most sites, such as phpfreaks has the img tags with brackets. Any suggestions how I'd go about doing that?

     

    All help appreciated!

  9. I can't get it to work when I include this piece:

    $userid = mysql_real_escape_string($_SESSION['userid']);
        //WALLNOT
       $db2 = "SELECT status FROM comments WHERE touser='$username' AND status='0'";
       $db2connect = $database->query($db2);
       
       $status2 = "SELECT status FROM friends2 WHERE user2='$username' and status='0'";
       $test = $database->query($status2);
       
       $statfromdb = "SELECT stat FROM wallposts WHERE person='$username' AND stat='0'";
       $status = $database->query($statfromdb);
       
       $GetStatus = "SELECT byuser, status, dtime FROM commentstatus WHERE status='$Naw'and person='$username' AND byuser!='$username'";
       $ConnectGetStatus = $database->query($GetStatus);
       
       $Getmsg = "SELECT status FROM messages WHERE status='0' AND touser='$username'";
       $ConnectGetmsg = $database->query($Getmsg);
    
       $row = mysql_fetch_array($test);
       $row2 = mysql_fetch_array($ConnectGetmsg);
       $getrow = mysql_fetch_array($status);
       $getrow2 = mysql_fetch_array($db2connect);
       $StatusComment = mysql_fetch_array($ConnectGetStatus);
       
               //Select profile picture
       $GetProfilePicture = "SELECT profilepicture FROM users WHERE username='$username'";
       $ConnectProfilePicture = $database->query($GetProfilePicture);
       $ProfilePicture = mysql_fetch_array($ConnectProfilePicture);
       $MyProfilePicture = $ProfilePicture['profilepicture'];

     

    I think it might have something to do with session.php.

    It says can't re-define db..

  10. I have this piece of code:

    function newmessage() {
      		box = new LightFace({ 
     			title: 'New message', 
    			width: 600,
    			height: 400,
      			content: "<form method='post' action='sendmessage.php'>To: <br><input type='text' name='to'><br><br>Subject: <input type='text' size='94' name='subject'><br><br><textarea name='message' rows='13' cols='63'></textarea><br><br><input type='submit' value='Send' name='send'><input name='from' type='hidden' value='<? echo $username; ?>'></form>",
     			buttons: [
    				{
    					title: 'Close',
    					event: function() { this.close(); }
    				}
    			]
     		});
     		box.open();		
     	}

     

    As well as this piece of code:

     $userid = mysql_real_escape_string($_SESSION['userid']);
        //WALLNOT
       $db2 = "SELECT status FROM comments WHERE touser='$username' AND status='0'";
       $db2connect = $database->query($db2);
       
       $status2 = "SELECT status FROM friends2 WHERE user2='$username' and status='0'";
       $test = $database->query($status2);
       
       $statfromdb = "SELECT stat FROM wallposts WHERE person='$username' AND stat='0'";
       $status = $database->query($statfromdb);
       
       $GetStatus = "SELECT byuser, status, dtime FROM commentstatus WHERE status='$Naw'and person='$username' AND byuser!='$username'";
       $ConnectGetStatus = $database->query($GetStatus);
       
       $Getmsg = "SELECT status FROM messages WHERE status='0' AND touser='$username'";
       $ConnectGetmsg = $database->query($Getmsg);
    
       $row = mysql_fetch_array($test);
       $row2 = mysql_fetch_array($ConnectGetmsg);
       $getrow = mysql_fetch_array($status);
       $getrow2 = mysql_fetch_array($db2connect);
       $StatusComment = mysql_fetch_array($ConnectGetStatus);
       
       		  //Select profile picture
    $GetProfilePicture = "SELECT profilepicture FROM users WHERE username='$username'";
    $ConnectProfilePicture = $database->query($GetProfilePicture);
    $ProfilePicture = mysql_fetch_array($ConnectProfilePicture);
    $MyProfilePicture = $ProfilePicture['profilepicture'];

     

    That I use in 19 different pages, is there anyway I can put them all into one page, and just them through a function?

     

    It takes so much time when loading if I have it on each page?

     

    And if you have any other tips how to optimize my loading speed please write them.

     

    Thank you in advance!

     

    *Edit: Bad grammar.

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