Please Help...Simple error (I think)

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
nishmgopal
Forum Contributor
Posts: 101
Joined: Tue Mar 03, 2009 9:38 am

Please Help...Simple error (I think)

Post 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!
JeffG
Forum Commoner
Posts: 35
Joined: Wed Jan 30, 2008 1:42 pm
Location: Newbury, UK

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

Post by JeffG »

If it's a session variable, don't you mean this?

Code: Select all

 
   $getjob = $_SESSION['job'];
 
nishmgopal
Forum Contributor
Posts: 101
Joined: Tue Mar 03, 2009 9:38 am

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

Post 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.
Post Reply