i need some help. i have a database and need some help in writing a quick script that will: 1)for each row grab the data from a given field. 2)pass is through a function (strips all spaces and wild characters) 3)inserts it into designated field. i'm sort of stuck because i don't know where to start. :\ is there a simple way to do this?
This is what I have come up with, but it is taking FOREVER... <?php include_once("db_connect.php"); $q = mysql_query("SELECT user FROM users"); while($results = mysql_fetch_object($q)) { $user = $results->user; $user_convert = urlconvert($results->user); $q1 = mysql_query("UPDATE users SET url_user = '".$user_convert."' WHERE user = '".$user."'"); } mysql_close($q); echo "Done!"; ?> PHP: urlconvert simply strips all spaces and add _ as well as periods and stuff like that. Anyone have a better method? Because this is taking forever!
1)for each row grab the data from a given field. select * from <Table_name> where <row_name>="user_name"; 2)pass is through a function (strips all spaces and wild characters) $row_num1="Samir $ % UK #@ "; $row_num2="United State Of America ! * PHP"; $special = array('/','!','&','*','%','-',' ','@','%','#'); // you can add whatever u want to remove from $new_row_num1 =str_replace($special,'',$row_num1); //$new_row_num1=SamirUK $new_row_num2 =str_replace($special,'',$row_num2); //$row_num2=UnitedStateOfAmericaPHP 3)inserts it into designated field. $q1 = mysql_query("UPDATE users SET url_user = '".$new_row_num1."' WHERE user ='".$user."'"); let me know if you ahve any Question regarding PHP script.