Jump to content

My scripts don't work with new .php version


Andrew R

Recommended Posts

I recently got a new web host that uses a newer .php version.  I've just realized that my scripts don't appear to work with it.

For example the scripts that pull information from the database by a name or an id in the URL etc don't work.

users.php?name=Bob

[code]$query_users = "SELECT * FROM user where name = '$name'";
$users = mysql_query($query_users) or die(mysql_error());
$row_users = mysql_fetch_assoc($users);[/code]

Anybody have any clue how to fix this as I'm really stuck.

Thanks
What is $name in this line:
$query_users = "SELECT * FROM user where name = '$name'";

If you're not doing something like $name = $_GET['name']; (missed filtering input out for simplicity) then it's because you were using register_globals before and that isn't supported now.

Dest
[quote author=pocobueno1388 link=topic=124432.msg515508#msg515508 date=1170008769]
Hmmm...doesn't look any different to me. Are you sure you defined $name?

What is the error, or what is happening?
[/quote]

I never had to define it before.. simply the name is gotten from the url eg user.php?name=Andrew

The only thing that is happening is that I can't see the results displayed... no error messages or anything.

[quote author=Destruction link=topic=124432.msg515515#msg515515 date=1170009248]
What is $name in this line:
$query_users = "SELECT * FROM user where name = '$name'";

If you're not doing something like $name = $_GET['name']; (missed filtering input out for simplicity) then it's because you were using register_globals before and that isn't supported now.

Dest
[/quote]

Cheers Dest I’ve got it working now with the $name = $_GET['name']; added in above the query.  Would anybody know how to modify the $name = $_GET['name']; inorder to add this function… $name = mysql_real_escape_string($name);

Cheers Again
The problem was that your script assumed register globals was on. Register globals is what automaticly makes your GET data in to vars with the same name. Register globals is now off by default since PHP 4.2.0, because of security.

The easy fix is just to do:
$name = $_GET['name'];

Or just use $_GET['name'] directly like pocobueno1388 showed you.

Archived

This topic is now archived and is closed to further replies.

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