Page 1 of 1

Please Help...Simple error (I think)

Posted: Sat Mar 07, 2009 1:35 pm
by nishmgopal
I have been pulling my hair out with this. My code is pasted below. Basically I have a variable stored in a session and I am trying to use it in an sql statement...why won't it work? I dont get any errors, just a blank page.

Code: Select all

 
 
<? session_start(); 
    
    $getjob = $_POST['job'];
    
    ?>
            <h1 class="title2">Find Suitable Candidate: <?php echo "$getjob" ?></h1>
 
.......
 
$query1 = "SELECT * FROM Job_Spec WHERE Project_Name='$getjob'";
            
  $result1 = mysql_query($query1)
       or die ("Couldn't execute query.");
 
 
Can anyone tell me what I have done wrong? When I change Project_Name='$getjob' to a name that actually is in the database it works fine!

Re: Please Help...Simple error (I think)

Posted: Sat Mar 07, 2009 1:42 pm
by JeffG
If it's a session variable, don't you mean this?

Code: Select all

 
   $getjob = $_SESSION['job'];
 

Re: Please Help...Simple error (I think)

Posted: Sat Mar 07, 2009 1:48 pm
by nishmgopal
I have changed it now to look like this:

Code: Select all

<? session_start(); 
    
    $getjob = $_SESSION['job'];
    
    ?>
 
My sql statement looks like this:

Code: Select all

 
$query1 = "SELECT * FROM Job_Spec WHERE Project_Name ='" . mysql_real_escape_string($getjob) . "'";
 
All I am getting is a blank screen with no errors.