Jump to content

MDanz

Members
  • Posts

    728
  • Joined

  • Last visited

Posts posted by MDanz

  1. at random times i get a parse error unexpected $end on a random line.  Then i refresh the page and everything is working.

     

    Does anyone have an idea on why this error is inconsistent? 

     

    It's hard to debug because i don't know when it's going to show up, completely random.  I have matched brackets and checked semicolons.  i would comment out code but like i said it's random.  If refreshing the page makes everything work, what could be the culprit?

  2. ok i don't understand.

     

     

    this is the line that causes it

     

     header( 'Location: ' . $return );

     

     

    The solution is to determine what that output is and prevent it from occurring before you attempt to do a header() redirect.

     

    $return is the url of the current page, so when logging out it reloads current page.

     

    What do i have to prevent?  I have a session_start(); at the top of the page is that what is causing it?

  3. i get the error "Warning: Cannot modify header information - headers already sent by" with the below code. How do i solve it without using output buffering?

     

    function logout($return) {
    
    	unset($_SESSION['admin']);
    	unset($_SESSION['username']);
      header( 'Location: ' . $return );
    echo "<div class='fontall'><span class='fontdif'>You've been logged out.  </span><a href='$return'>Click Here</a><span class='fontdif' to return</span></div>";
    
    	}

  4. When i check the source code I get this error

     

    rotator cuff<br />strengthenin<br..

     

    you can see the br tag is cutt off.  The code is below.

     

    $thename = "rotator cuff strengthening";

     

    	$newname = wordwrap($thename, 12, "<br />", true);
    
    $limit = 33;
    
    	if (strlen($newname) > $limit)
    	{ 
    		 $newname2 = substr($newname, 0, $limit) . '..'; 
    
    	 }
    		 else
    	{
    		$newname2 = $newname;
    
    	}			
    

  5. With this form... if i typed in "new test" in the search text field the url would come up as

     

    test.php?search=new+test

     

    How do i get the url to replace spaces as a dash instead of a plus sign?

     

    <form action="test.php" method="GET" name="searchbar">
    
    		<?php 
    
    
    	$search = strtolower($_GET['search']);
    
    	$formpage = $_SERVER['PHP_SELF'];
    
    echo "<input type='text' size='40' name='search' style='font-size:16px; font-family:Arial;font-weight:bold;' />  <input type='submit'  value='Search' style='font-size:14px;' />";
    
    		?>
    
    			</div>
    
    	</form>

  6. this query isn't working.

     

    foreach($rating as $value) //foreach loop which updates totalsum every array key
    		{
    
    			if($value>0) {
    			$totalsum = mysql_query("UPDATE block SET totalsum=totalsum+$value WHERE id=$d",$this->connect);
    			}
    		}
    

     

    i echoed the query and get this

     

    UPDATE block SET totalsum=totalsum+2 WHERE id=16 AND id=17 AND id=18 AND id=19

     

    it should work. I have entries in mysql with those id's. It should update the totalsum column by 2 for those id's

  7. $_SESSION['people'] is an array.  I add to $_SESSION['people'] by doing this...

    $_SESSION['people'][] = $people;

     

    basically how do i code "if last key in array?"..

     

    i tried this but it's not correct

     if(end($_SESSION['people'])) {
        //code
    
        }

  8. How do i do if i've reached of array?  i know i could do end of loop.  but the array is present many times in my code.

     

    while($row = mysql_fetch_assoc($getdetails)) {
    $people = $row['people'];
    $_SESSION['people'][] = $people;
    
        if(end($_SESSION['people'])) {
        //code
    
        }
    }
    

  9. i want the div to start off hidden.  I know how to make it show and hide.  The problem is when i load the page the border is seen. If i use display:none; in the div css the div doesn't display even when i press the button with the function to show.

     

    open and close function

    function infobox(number) {
    document.getElementById('userinfo').style.display = "block"; //displays userinfo
      
    }
    
    function closeinfo() {
    document.getElementById('userinfo').style.display = "none";
    
    }
    
    

     

    div css

    #userinfo {
    position:absolute;
    text-align:left;
    width:900px;
    height:auto;
    top:100px;
    left:50%;
    font-size:14px; 
    font-family:Arial;
    z-index:20;
    margin-left:-450px;
    background-color:#FFFFFF;
    border:1px solid #264971;
    
    }

  10. i put values in the array like this

     

    $_SESSION[$v][] = "<div class='informationtop'></div>
    		<div class='informationmiddle'><p>Added by <b>$theuser</b></p><p>$name</p><p>$reason</p></div>
    		<div class='informationbottom'></div>";

     

    if i print_r($_SESSION[1]);  the array has the correct values.  but for some reason the error is showing up.

  11. i keep on getting this error..  Warning: implode() [function.implode]: Invalid arguments passed in...

     

    $rowinformation is an array, i don't see where the problem is.

     

    	for($v=1;$v<11;$v++) {
    	$rowinformation = $_SESSION[$v];
    	echo "<div style='display:none;' id='$v'>".implode("<p> </p>",$rowinformation)."</div>"; // outcome string information
    
    	}

  12. it's not displaying the image... any help?

     

    echo "<img src='advertimage.php?id=$advertid' />"; 

     

    advertimage.php

    <?php
    
    $id= $_GET['id'];
    
    $thedatabase = new Database2();
    $thedatabase->opendb2();
    
    $advert = $thedatabase->viewadvert($id);
    header("Content-type: image/jpeg");
      echo $advert;
    $thedatabase->closedb2();
    
    ?> 

     

     

    viewadvert function

    function viewadvert($id){
    $getadvert = mysql_query("SELECT * FROM `advertise` WHERE `id`='$id' LIMIT 1",$this->connect);
    
    $row=mysql_fetch_assoc($getadvert);
    
    $image = $row['image'];
    
    return $image;
    
    }

     

     

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