Jump to content

Can't see why this sql string is not working


boylesg

Recommended Posts

Is there a deliberate policy of not allowing pasting of text directly into the post window or is there something wrong with my browser settings?

Because I have to say it is a PAIN IN THE ARSE not being able to do so.

 

Here is the function being called:

function getOverheadDetailsShortkey($DailyDetailsShortkey, $OverheadType, $OverheadHours){    $SQLString = "SELECT * FROM DailyOverheadDetails WHERE DailyDetailsShortkey=".$DailyDetailsShortkey." AND OverheadType='".$OverheadType."' AND Hours='".$OverheadHours."'";	$Shortkey = -1;	if ($QueryResult = doDBOp($SQLString, "", ""))	{echo "1111111111111111111<br>";        if ($Row = mysqli_fetch_assoc($QueryResult))         {echo "2222222222222222222<br>";			$Shortkey = $Row["Shortkey"];		}	}echo "ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ<br>";echo $SQLString."<br>";echo $Shortkey."<br>";echo "ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ<br>";	return $Shortkey;}

Here is the data in the table:

Table: DailyOverheadDetailsShortkey        DailyDetailsShortkey      OverheadType              Hours  -------------------------------------------------------------------------------50              107                       Website                   3.549              107                       Vehicle maintenance       0.548              106                       Website                   3.547              106                       Vehicle maintenance       0.546              105                       Website                   3.5 45 		105 			  Vehicle maintenance       0.5 

This is my debug output showing the constructed SQL string.

ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZSELECT * FROM DailyOverheadDetails WHERE DailyDetailsShortkey=107 AND OverheadType='Vehicle maintenance' AND Hours='0.5'-1ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ1111111111111111111ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZSELECT * FROM DailyOverheadDetails WHERE DailyDetailsShortkey=107 AND OverheadType='Website' AND Hours='3.5'-1ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ

So why is my code and SQL string failing to find the record with DailyDetailsShortkey=107, OverheadType='Vehicle mainenance', Hours='0.5', because it clearly exists.

 

What am I doing wrong?

Edited by Greg Boyles
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...