PHP help with filename.php?value=12

Discussion in 'OT Technology' started by CyberBullets, Jul 16, 2003.

  1. CyberBullets

    CyberBullets I reach to the sky, and call out your name. If I c

    Joined:
    Nov 13, 2001
    Messages:
    11,865
    Likes Received:
    0
    Location:
    BC, Canada/Stockholm, Sweden
    how do i retrive that value of 12??

    TIA
     
  2. eof

    eof New Member

    Joined:
    Jan 17, 2002
    Messages:
    7,288
    Likes Received:
    0
    $value
    is the variable...

    echo $value;
    would print the value....
     
  3. CyberBullets

    CyberBullets I reach to the sky, and call out your name. If I c

    Joined:
    Nov 13, 2001
    Messages:
    11,865
    Likes Received:
    0
    Location:
    BC, Canada/Stockholm, Sweden
  4. CyberBullets

    CyberBullets I reach to the sky, and call out your name. If I c

    Joined:
    Nov 13, 2001
    Messages:
    11,865
    Likes Received:
    0
    Location:
    BC, Canada/Stockholm, Sweden
    doesnt seem to work.

    still doesnt return anything even if i echo it
     
  5. CyberBullets

    CyberBullets I reach to the sky, and call out your name. If I c

    Joined:
    Nov 13, 2001
    Messages:
    11,865
    Likes Received:
    0
    Location:
    BC, Canada/Stockholm, Sweden
    i needed to do this

    PHP:
    <?php 
    session_start
    (); 
    session_register('value'); 
    ?>
     
  6. CyberBullets

    CyberBullets I reach to the sky, and call out your name. If I c

    Joined:
    Nov 13, 2001
    Messages:
    11,865
    Likes Received:
    0
    Location:
    BC, Canada/Stockholm, Sweden
    now i get this! joy!

    Warning: session_start(): open(/tmp\sess_c1981bf6699d293c8508f71e5bc30b3a, O_RDWR) failed: No such file or directory (2) in d:\cyberbullets.net\public_html\comments.php on line 33

    Warning: session_start(): Cannot send session cookie - headers already sent by (output started at d:\cyberbullets.net\public_html\comments.php:12) in d:\cyberbullets.net\public_html\comments.php on line 33

    Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at d:\cyberbullets.net\public_html\comments.php:12) in d:\cyberbullets.net\public_html\comments.php on line 33
    is entryUnable to run query.
    Warning: Unknown(): open(/tmp\sess_c1981bf6699d293c8508f71e5bc30b3a, O_RDWR) failed: No such file or directory (2) in Unknown on line 0

    Warning: Unknown(): Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/tmp) in Unknown on line 0
     
  7. Penguin Man

    Penguin Man Protect Your Digital Liberties

    Joined:
    Apr 27, 2002
    Messages:
    21,696
    Likes Received:
    0
    Location:
    Edmonton, AB
    Should be able to use $_value as well, or the old way (I think) $HTTP_GET_VARS["value"].
     
  8. eof

    eof New Member

    Joined:
    Jan 17, 2002
    Messages:
    7,288
    Likes Received:
    0
    shouldn't have to do that....if you are using it in functions make sure you have it as a global inside the function...

    e.g
    function fuckedUpFunction() {
    global $variable;
    }
     
  9. CyberBullets

    CyberBullets I reach to the sky, and call out your name. If I c

    Joined:
    Nov 13, 2001
    Messages:
    11,865
    Likes Received:
    0
    Location:
    BC, Canada/Stockholm, Sweden
    leme post my sloppy php code for u guys

    the link to the page is comments.php?entry=19
    Code:
    <?php
            session_start(); 
            session_register('value'); 
    ?>
    
    <html>
     <head>
      <link rel="stylesheet" type="text/css" href="index.css">
      <title>.: CyberBullets dot Net :.</title>
     </head>
    
     <body>
      <!-- Top Banner Area -->
      <table width="100%" align="center">
       <tr>
        <td valign="top" align="center">
    	 <? include('title.php'); ?>
    	</td>
       </tr>
      </table>
    
      <br>
    
      <!-- Left Select Column -->
      <table width="130px" align="left">
       <tr>
        <td>
    	 <? include('toolbar.php'); ?>
    	</td>
       </tr>
      </table>
    
      <!-- Main Posting Area -->
      <table align="right" width="86%">
       <tr>
        <td>
         <?php
    		//$hd = mysql_connect("localhost", "cyberbu_cyberbul", "cyberb") 
    		$hd = mysql_connect("localhost", "", "") 
    			 or die ('I cannot connect to the database because: ' . mysql_error());
    		mysql_select_db ("blog"); 
    
    		//$entry = mysql_escape_string("entry");
    		//$password = mysql_escape_string($_POST["password"]);
    
    		echo "$entry is entry";
    
    		$sql = "SELECT * FROM entry where eid=$entry;";
    
    		$res = mysql_query($sql, $hd)
    			  or die ("Unable to run query.");
    
    		$nrows = mysql_num_rows($res);
    
            while($row = mysql_fetch_assoc($res))
            {
    			$eid = $row["eid"];
    			$title = $row["title"];
    			$user = $row["user"];
    			$email = $row["email"];
    			$body = $row["body"];
    			$date = $row["date"];
    
    			if($nrows>0){
    				echo "<tr><td>";
    				echo "<hr width=\"270px\" color=\"#000000\" size=\"3px\" align=\"left\">\n";
    				echo "<b>#$eid - $title</b><br>\n";
    				echo "<u>$date UTC</u> - <i><a href=\"mailto:$email?Subject=$title\">$user</a></i><br>\n";
    				echo "<hr width=\"270px\" color=\"#000000\" size=\"3px\" align=\"left\">\n";
    				echo "$body\n";
    				echo "<hr width=\"100%\" color=\"#000000\" size=\"3px\" align=\"center\">\n";
    				echo "Comments<br><br>";
    				
    				$sql = "SELECT * FROM comments where eid=$entry;";
    
    				$res = mysql_query($sql, $hd)
    					  or die ("Unable to run query.");
    
    				$nrows = mysql_num_rows($res);
    
    				while($row = mysql_fetch_assoc($res))
    				{
    					$username = $row["username"];
    					$email = $row["username"];
    					$comment = $row["comment"];
    
    					if($nrows>0){
    					}else{
    						echo "No Replies";
    					}
    				}
    			}else{
    			
    			
    			}
    		}
    
    		mysql_close($hd);
    	 ?>
    	</td>
       </tr>
      </table>
     </body>
    
    </html>
    
     
  10. Penguin Man

    Penguin Man Protect Your Digital Liberties

    Joined:
    Apr 27, 2002
    Messages:
    21,696
    Likes Received:
    0
    Location:
    Edmonton, AB
    According to the PHP manual, the old way is:
    Code:
    global $HTTP_GET_VARS;
    $HTTP_GET_VARS['value'];
    and the new way is:
    Code:
    $value
    Either way works on my machine.
     
  11. CyberBullets

    CyberBullets I reach to the sky, and call out your name. If I c

    Joined:
    Nov 13, 2001
    Messages:
    11,865
    Likes Received:
    0
    Location:
    BC, Canada/Stockholm, Sweden
    got it!

    $temp = $HTTP_GET_VARS["entry"]; worked

    tkx for ur help
     
  12. crotchfruit

    crotchfruit Guest

    url request: http://blah.com/file.php?value=12

    look in your php.ini file for something like "register_globals = on" [off]. if register_globals is on, it means that when the php script runs it will automatically define all of the get/post variables for as $var_name (where var_name is the name of the value.) if register_globals is off, it will not do this. keep in mind that on new versions of php, register_globals defaults to off for security reasons (basically, if you forget to initialize a variable someone could pass in a fake get value and screw with your scripts.) my guess is that you didn't turn register_globals on, so you couldn't access $value.

    --
    global $HTTP_GET_VARS;
    $HTTP_GET_VARS['value'];
    --

    this is the old way. the new, correct way to access these values is through the $_GET[] and $_POST[] variables. so in the top case you would do:

    echo $_GET['value'];

    $_GET is basically the same as $HTTP_GET_VARS but is the 'new' way.
     

Share This Page