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

c++ - Function signature as a function template parameter -

How to call a javascript function after the page loads with a chrome extension? -

algorithm - What are some ways to combine a number of (potentially incompatible) sorted sub-sets of a total set into a (partial) ordering of the total set? -