mysql - Can PHP 5.4 run on PHP 5.3 configured server -


first of all, novice web developer.

my question "a website developed php 5.4 can run on php 5.3 configured server?"

(detail description) configure myself apache 2.4, mysql 5.6 , php 5.4.12 on windows. everything's ok. errors occur when changed website folder machine configured wampserver. wampserver configured apache 2.2.11, php 5.3 , mysql 5.1.36.

i install mysql 5.6 on machine , database connected. "parse error occur code" such

$country = mysql_fetch_row(querymysql("----"))[0];

in addition, showed other errors such "table 'emp.productcateogry' doesn't exist".

please, give me suggestions.

the short answer is: no, should not expect to, if using new features of php 5.4 within code.

the specific error referring with:

parse error occur code

is because line

$country = mysql_fetch_row(querymysql("----"))[0]; 

is using new feature:

function array dereferencing

which, prior php 5.4, had use temporary variable in order access specific index of return, ie:

$country_temp = mysql_fetch_row(querymysql("----")); $country = $country_temp[0]; 

now, being novice developer, there few things should note. first , important being mysql_ functions deprecated giving note:

this extension deprecated of php 5.5.0, , removed in future. instead, mysqli or pdo_mysql extension should used.

in other words, use pdo if wanting use prepared statements, or mysqli if not. advantage of using pdo , obtaining 1 column in example code once connected, can use function pdostatement::fetchcolumn() obtain 1 column trying now.

anyways, hope explanation helps understand why can't go php 5.3.x if using specific php 5.4 abilities - , understanding of how improve database connection , available functions can desired result without using "array dereferencing" provided php 5.4. ^^


Comments

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -