Andrew R Posted January 28, 2007 Share Posted January 28, 2007 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 Link to comment https://forums.phpfreaks.com/topic/36081-my-scripts-dont-work-with-new-php-version/ Share on other sites More sharing options...
pocobueno1388 Posted January 28, 2007 Share Posted January 28, 2007 Hmmm...doesn't look any different to me. Are you sure you defined $name?What is the error, or what is happening? Link to comment https://forums.phpfreaks.com/topic/36081-my-scripts-dont-work-with-new-php-version/#findComment-171250 Share on other sites More sharing options...
Destruction Posted January 28, 2007 Share Posted January 28, 2007 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 Link to comment https://forums.phpfreaks.com/topic/36081-my-scripts-dont-work-with-new-php-version/#findComment-171257 Share on other sites More sharing options...
Andrew R Posted January 28, 2007 Author Share Posted January 28, 2007 [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=AndrewThe 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 Link to comment https://forums.phpfreaks.com/topic/36081-my-scripts-dont-work-with-new-php-version/#findComment-171268 Share on other sites More sharing options...
pocobueno1388 Posted January 28, 2007 Share Posted January 28, 2007 [code]$name = mysql_real_escape_string($_GET['name']);[/code] Link to comment https://forums.phpfreaks.com/topic/36081-my-scripts-dont-work-with-new-php-version/#findComment-171271 Share on other sites More sharing options...
Andrew R Posted January 28, 2007 Author Share Posted January 28, 2007 Thanks very much pocobueno1388 :) Link to comment https://forums.phpfreaks.com/topic/36081-my-scripts-dont-work-with-new-php-version/#findComment-171287 Share on other sites More sharing options...
Hypnos Posted January 28, 2007 Share Posted January 28, 2007 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. Link to comment https://forums.phpfreaks.com/topic/36081-my-scripts-dont-work-with-new-php-version/#findComment-171328 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.