Frank100 Posted June 25, 2007 Share Posted June 25, 2007 Question, is the connection done with the following $cxn already ? Or is this just defining a variable which will be executed later in the $result ? If just a variable definition, how would I execute $ result ? $cxn = mysqli_connect($host,$user,$password,$database) or die ("Couldn't connect to server"); $result = mysqli_query($cxn,$query) or die ("Couldn't execute insert query"); Regards, Frank Link to comment https://forums.phpfreaks.com/topic/57032-does-defining-a-variable-already-executes-it/ Share on other sites More sharing options...
pocobueno1388 Posted June 25, 2007 Share Posted June 25, 2007 Yes, that will connect you =] It doesn't matter if it is in a variable or not. Link to comment https://forums.phpfreaks.com/topic/57032-does-defining-a-variable-already-executes-it/#findComment-281722 Share on other sites More sharing options...
soycharliente Posted June 25, 2007 Share Posted June 25, 2007 What would saving it to a variable do? Just tell you whether or not is executed without any errors? Link to comment https://forums.phpfreaks.com/topic/57032-does-defining-a-variable-already-executes-it/#findComment-281728 Share on other sites More sharing options...
ToonMariner Posted June 25, 2007 Share Posted June 25, 2007 Variables are not executed - they are 'used'. In php the mysql(i)_connect is a construct that creates a resource. This resource is used in subsequent interactions with the database. Link to comment https://forums.phpfreaks.com/topic/57032-does-defining-a-variable-already-executes-it/#findComment-281737 Share on other sites More sharing options...
Frank100 Posted June 25, 2007 Author Share Posted June 25, 2007 thx for the replies, so when I understand right in the following sample $qry is not creating a variable because it creates a resource that immediately is executed ? <?php $qry =mysql_query("SELECT * FROM `staff` WHERE `clue` > 0"); echo mysql_num_rows($qry); ?> Link to comment https://forums.phpfreaks.com/topic/57032-does-defining-a-variable-already-executes-it/#findComment-281754 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.