DataRater Posted August 19, 2008 Share Posted August 19, 2008 PHP 5 MySQL 5 Basically I have one connection doing a select and print loop and a second doing an update which increments the count of the times it is displayed. The problem is the value of count is not being incremented when it comes back from the database. So that makes me look in the database and sure enough it isn't. So I'm wondering if the two connections are fighting one another and I would like a solution. $Connection1 = @mysqli_connect( 'host', 'user', 'pw','db' ); $sql = "SELECT * FROM Cars"; $ResultSet1 = mysqli_query($Connection1, $sql ); mysqli_data_seek($ResultSet1,0); while ( list($id,$name, $manufacturer, $model, $count ) = mysqli_fetch_row($ResultSet1) ) { $general_query_count++; $sql = "UPDATE Cars SET general_query_count=".$general_query_count.$Space."WHERE id ='".$id."'"; $Connection2 = @mysqli_connect( 'host', 'user', 'pw','db' ); $ResultSet2 = mysqli_query($Connection2, $sql ); if (!is_null($name)){ $name = nl2br(htmlspecialchars($name))."<br />";} if (!is_null($manufacturer)){ $manufacturer = nl2br(htmlspecialchars($manufacturer))."<br />";} f (!is_null($model)){ $model = nl2br(htmlspecialchars($model))."<br />";} ********* Print the data********** } Quote Link to comment Share on other sites More sharing options...
DataRater Posted August 19, 2008 Author Share Posted August 19, 2008 The problem appears to be that $general_query_count is not being queried from the database properly. I'm investigating... Quote Link to comment Share on other sites More sharing options...
DataRater Posted August 19, 2008 Author Share Posted August 19, 2008 I've solved it. The while(list( doesn't have sufficient elements for the * in the select statement. Duhhhhhhh $sql = "SELECT * FROM Cars"; $ResultSet1 = mysqli_query($Connection1, $sql ); mysqli_data_seek($ResultSet1,0); while ( list($id,$name, $manufacturer, $model, $count ) = mysqli_fetch_row($ResultSet1) ) Quote Link to comment 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.