esiason14 Posted April 1, 2007 Share Posted April 1, 2007 I'm parsing my pages to find all id's. What I want to do is: if the id already exists in my db then I want to update it...if not I want to insert a record. How can I go about doing that. Any help would be appreciated. Thanks!! foreach ($url as $value) { $base = "http://www.mypage.com/whatever"; $getit = "".$base."$value"; $input = file_get_contents("$getit"); preg_match_all('@<a href="/whatever/([A-Za-z0-9-]+)">(.*?), (.*?)</a>@', $input, $matches); for($i=0;$i<40;$i++) { $sql3 = "SELECT id from mlbplayers where id=".$matches[1][$i].""; while ($row3 = mysql_fetch_assoc($result3)) { $pid = $row3["id"]; } echo "$sql3<br />"; } } Quote Link to comment Share on other sites More sharing options...
jaku78 Posted April 1, 2007 Share Posted April 1, 2007 $sql3 = "SELECT id from mlbplayers where id=".$matches[1][$i].""; You cannot have code like this. You're confusing the PHP with double quotes IN double quotes. You should have it like this. $sql3 = "SELECT id from mlbplayers where id='.$matches[1][$i].'"; When you cannot use double quotes in html, php, sql, you usually use a alternative like '. 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.