Jump to content

Recommended Posts

Hi I have an error on line $test = "NULL"; in

function GetAllData($StartDate, $View) {
		$test = "NOT NULL";
		if($View == NULL
	{
		$test = "NULL"; // error Parse error: syntax error, unexpected token ";" in /vhost/d/e/s/desmond-otoole.co.uk/www/bank2/secure/SecureFunctionsBankPDO.php on line 32
	}
	
	StoreData($StartDate . " Len: " . strlen($View) . "- " . $test); // *** Store data to trap this error ***
    $pdo = connectDB();
	
	
	if($View == 'Show' or $View == 'Show+' . if($View == NULL)  //Desmond. or Desmond..
	{
		$sqlAllData = "SELECT * FROM Bank_Data WHERE EntryDate > ? AND EntryDate <= DATE_ADD(?, INTERVAL  6 WEEK) ORDER BY EntryDate ASC, Output";
		$stmt = $pdo->prepare($sqlAllData);
		$stmt->execute( [ $StartDate, $StartDate] ); 
		return $stmt;		
	}
	
	if($View == 'Total' or $View == 'Database' )
	{
		$sqlAllData = "SELECT * FROM Bank_Data ORDER BY EntryDate ASC, Output";
		$stmt = $pdo->prepare($sqlAllData);
		$stmt->execute();	
		return $stmt;
	}
}

Seems okay to me.

 

 

Link to comment
https://forums.phpfreaks.com/topic/330656-unexpected/
Share on other sites

firstly, this question is a php question. not a mysql question.

the syntax of your if() {} conditional statement is broken. the ) is missing.

there's no guarantee that the incorrect value is a NULL. i showed you in a previous thread how you can use var_export() to cause the actual value to be used in the storedata(...) call.

Link to comment
https://forums.phpfreaks.com/topic/330656-unexpected/#findComment-1659856
Share on other sites

As I said previously I can not use storedata(...)  here. I am entering this data into a database table with the field value as Page as varchar(20). I have used this

    $test = "NOT NULL";
    if($View === NULL)
        $test = "NULL";
And add this into the database field. When the problem re accours I can check the database.

Link to comment
https://forums.phpfreaks.com/topic/330656-unexpected/#findComment-1659861
Share on other sites

6 hours ago, Paul-D said:

As I said previously I can not use storedata(...)  here. I am entering this data into a database table with the field value as Page as varchar(20). I have used this

    $test = "NOT NULL";
    if($View === NULL)
        $test = "NULL";
And add this into the database field. When the problem re accours I can check the database.

I just pasted the code you provided.  Along with what Mac stated, you have syntax errors.  He already explained this to you, as your code is missing the required end parentheses.  

I have no idea what you were trying to do with the code in my message  -- it makes on sense, and looks like you accidentally copy/pasted a snippet from somewhere.  Again, all conditions have to have parentheses around them!

 

if (condition) {
   // condition evaluates to true
} else {
   // condition evaluated to false
}

 

Link to comment
https://forums.phpfreaks.com/topic/330656-unexpected/#findComment-1659864
Share on other sites

Update on  what I said previously. I am entering into a database table the following

Date of entry plus strlen($View) . $test [Is this NULL]

The result of  

$test = "NOT NULL";
    if($View === NULL)
        $test = "NULL";

I have got 

2025-09-22 (0) NOT NULL

a string that is lenthe  0 and it is NOT NULL

Sugestion was to use var_export() so I have tested this

 $View = $_SESSION['CounterValue'];
		echo "Value: " . var_export($View);
		exit;

Result: ''Value: <nothing follows>

In the php manual https://www.php.net/manual/en/function.var-export.php

All I get is the contents of the variable nothing else. What was I suposed to see here? Type of variable[string]? IS NULL? value if exists all the under the bonnet info on this variable. All I got was nothing. What my method showd was, it is NOT NULL and a zero length string. Which is more information than I got from var_dump()

 

 

Edited by Paul-D
Link to comment
https://forums.phpfreaks.com/topic/330656-unexpected/#findComment-1659874
Share on other sites

We are having issues understanding what your question is.

These are 2 different things in PHP.

A variable that is set to null has no value and no type.

<?php
$var = null;
$str = '';

echo gettype($var) . PHP_EOL;
echo gettype($str) . PHP_EOL;

var_export($var);
echo PHP_EOL;
var_export($str);

Output:

NULL
string
NULL
''

 

If you want to use var_export as a string, you need to pass true as the 2nd parameter.

echo "Value: " . var_export($View, true);

 

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/330656-unexpected/#findComment-1659887
Share on other sites

the OP was already told how to use var_export -

https://forums.phpfreaks.com/topic/330113-ongoing-problem-with-missing-session-variables/#findComment-1657999

then given a copy/paste use -

https://forums.phpfreaks.com/topic/330113-ongoing-problem-with-missing-session-variables/#comment-1659430

edit: and this problem isn't going to go away until the only session variable that is an input to this 'statement' code is the logged in user's id, so that the only code that affects what the processing is and what is displayed on this page, is the code on this page, and not in any processing on other pages.

Edited by mac_gyver
Link to comment
https://forums.phpfreaks.com/topic/330656-unexpected/#findComment-1659889
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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