ali_2kool2002 Posted March 11, 2007 Share Posted March 11, 2007 hi does anyone know some code in php that could refresh the database? thanks Link to comment https://forums.phpfreaks.com/topic/42215-refreshing-the-database/ Share on other sites More sharing options...
brown2005 Posted March 11, 2007 Share Posted March 11, 2007 what u mean by refresh the database? Link to comment https://forums.phpfreaks.com/topic/42215-refreshing-the-database/#findComment-204764 Share on other sites More sharing options...
tauchai83 Posted March 11, 2007 Share Posted March 11, 2007 did you mean to refresh the whole DB just like you refresh it in phpmyadmin? Link to comment https://forums.phpfreaks.com/topic/42215-refreshing-the-database/#findComment-204765 Share on other sites More sharing options...
ali_2kool2002 Posted March 11, 2007 Author Share Posted March 11, 2007 well im inserting a new record with a value id say "2" in one of the fields but if i click the back button on the web browser, and then go forward to the same original php page that inserts the record, it still thinks that the record i added has not beed added and so adds another record with the same value... the problem is i dont want it to be able to insert records if the id 2 allready exists in the table, so was wondering if i could refresh the database somehow and then check if it exists. hope this helps :'( :'( Link to comment https://forums.phpfreaks.com/topic/42215-refreshing-the-database/#findComment-204766 Share on other sites More sharing options...
tauchai83 Posted March 11, 2007 Share Posted March 11, 2007 can you post your code? you used mysql_insert_id to insert next new id? Link to comment https://forums.phpfreaks.com/topic/42215-refreshing-the-database/#findComment-204769 Share on other sites More sharing options...
ali_2kool2002 Posted March 11, 2007 Author Share Posted March 11, 2007 <?php require_once('mysql_connect.php'); if (isset($_POST['submitted'])) { if (empty ( $_POST['driverId'] ) ){ echo "empty"; } else{ $driverId = $_POST['driverId']; $check_if_already_exists = "select driverId from delivery where driverId = '$driverId'"; $check_result = mysql_query($check_if_already_exists) or die ("couldnt execute query"); if (mysql_num_rows($check_result) >1) { ?> <script language="Javascript"> alert ( "driver all ready exists") </script> <? } else{ $driverId = $_POST['driverId']; $get_Name = "select driverName from driver where driverId = $driverId"; $get_name_res = mysql_query($get_Name) or die(mysql_error()); while ($results = mysql_fetch_array($get_name_res, MYSQL_ASSOC)) { echo '<tr><td align="center"><b>You have selected : </b> ' . $results['driverName'] . '</td></tr><br /> '; echo "new delivery created"; //INSERT NEW DELIVERY RECORD $insert_query = "INSERT INTO `delivery` (`deliveryId`, `driverId`, `deliveryDate`) VALUES (NULL, '$driverId ', now())"; $result = mysql_query($insert_query) or die ("couldnt execute query"); echo "<B> new delivery created </B><br />"; } } Link to comment https://forums.phpfreaks.com/topic/42215-refreshing-the-database/#findComment-204773 Share on other sites More sharing options...
ali_2kool2002 Posted March 11, 2007 Author Share Posted March 11, 2007 sorri it is quite a big chunk of code but ,, if i refresh the actual page (ie browser) 2 times, then after that the sql databse updates and the php recognises that there is an existing record with the same driver id ... i jus thought someone may know if there is a code in php to update mysql databse straight after inserting a record..? Link to comment https://forums.phpfreaks.com/topic/42215-refreshing-the-database/#findComment-204776 Share on other sites More sharing options...
legohead6 Posted March 11, 2007 Share Posted March 11, 2007 thats just something your going to have to live with, or you could make another query that checks if its been posted. Link to comment https://forums.phpfreaks.com/topic/42215-refreshing-the-database/#findComment-204868 Share on other sites More sharing options...
legohead6 Posted March 11, 2007 Share Posted March 11, 2007 an efficent site should be able to run without those browser buttons.. Link to comment https://forums.phpfreaks.com/topic/42215-refreshing-the-database/#findComment-204869 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.