Strict Standards: Only variables should be passed by reference in C:\xampp\htdocs\cart\ajax\tips.php on line 8

Recommended Answers

Can't really help you without seeing what the code before, on and after line 8 looks like.

Without seeing code I'm assuming your passing something like the return of explode() directly into another function. e.g. $foo = array_shift( explode( '.', $bar ) );

Jump to Post

Post your code..

Jump to Post

Strict Standards: Only variables should be passed by reference

Try changing code at line number 8:

$imagename = end(explode('/',$_POST['img']));
$img = mysql_real_escape_string($imagename);
Jump to Post

All 9 Replies

Can't really help you without seeing what the code before, on and after line 8 looks like.

Without seeing code I'm assuming your passing something like the return of explode() directly into another function. e.g. $foo = array_shift( explode( '.', $bar ) );

Post your code..

<?php

define('INCLUDE_CHECK',1);
require "../connect.php";

if(!$_POST['img']) die("There is no such product!");

$img=mysql_real_escape_string(end(explode('/',$_POST['img'])));

$row=mysql_fetch_assoc(mysql_query("SELECT * FROM internet_shop WHERE img='".$img."'"));

if(!$row) die("There is no such product!");

echo '<strong>'.$row['name'].'</strong>

<p class="descr">'.$row['description'].'</p>

<strong>price: $'.$row['price'].'</strong>
<small>Drag it to your shopping cart to purchase it</small>';
?>

Strict Standards: Only variables should be passed by reference

Try changing code at line number 8:

$imagename = end(explode('/',$_POST['img']));
$img = mysql_real_escape_string($imagename);

vibhaj:

$imagename = end(explode('/',$_POST['img']));
$img = mysql_real_escape_string($imagename);

still the same error :(

$imagename = end(explode('/',$_POST['img']));
$img = mysql_real_escape_string($imagename);

Does not resolve the pass by reference issue given the ops original code.

$parts = explode('/',$_POST['img'])
$imagename = end( $parts );
$img = mysql_real_escape_string($imagename);

Should resolve the issue as the return of explode is not passed directly into another function call.

$parts = explode('/',$_POST['img'])
$imagename = end( $parts );
$img = mysql_real_escape_string($imagename);

thank you so much :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.