nathanmaxsonadil Posted August 26, 2007 Share Posted August 26, 2007 I was wondering why people go like this $somevar = "mysql query"; $somevar2 = mysql_query($somevar); instead of just going $somevar = mysql_query("mysql query"); ? Quote Link to comment https://forums.phpfreaks.com/topic/66786-solved-mysql_query-or/ Share on other sites More sharing options...
pocobueno1388 Posted August 26, 2007 Share Posted August 26, 2007 I would say mostly for error handling. If you store the query as a string you can easily echo it out and see if theres a problem. Also, it makes it easy to add to the query. If you just put it into the mysql_query(), you can't really do anything with it, it's stuck the way it is. There may be other reasons that other people do it for, but those ones seem the most obvious to me. Quote Link to comment https://forums.phpfreaks.com/topic/66786-solved-mysql_query-or/#findComment-334646 Share on other sites More sharing options...
nathanmaxsonadil Posted August 26, 2007 Author Share Posted August 26, 2007 k thanks Quote Link to comment https://forums.phpfreaks.com/topic/66786-solved-mysql_query-or/#findComment-334647 Share on other sites More sharing options...
Wuhtzu Posted August 26, 2007 Share Posted August 26, 2007 Because they think it's easier / more readable to have the actual mysql query standing by it self instead of inside the mysql_query() function? I personally do: $get_or_insert_something = mysql_query("some query") At least when I'm not using a framework or just creating some small script. Quote Link to comment https://forums.phpfreaks.com/topic/66786-solved-mysql_query-or/#findComment-334648 Share on other sites More sharing options...
Wuhtzu Posted August 26, 2007 Share Posted August 26, 2007 The reason pocobueno1388 list are pretty good too Quote Link to comment https://forums.phpfreaks.com/topic/66786-solved-mysql_query-or/#findComment-334650 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.