phpnewby1918 Posted May 2, 2010 Share Posted May 2, 2010 Hi I'm firstly sorry about this because i literally don't know what i've done to stop my php working past a point on my xampp. I have been just fiddling around and now i cant get it to even echo out 'Hello' any more (After i've executed a piece of code) I know its something in the script above because when i '/*' it out it ran my code below it, which was just recalling mysql db info, it worked fine. I've since removed this lower peice of code as i wasnt sure if it was a problem with calling to the database or php itself. But it seems to be php itself as you'll be able to see i've just asked it to echo out hello and the won't even do that. I'm sure its really simple but one of those things where you cant see the woods for the trees. Here is my code: <?php require("connect.php"); ?> <?php $extract = mysql_query ("SELECT * FROM rss"); $numrows = mysql_num_rows($extract); while ($row = mysql_fetch_assoc($extract)) { $id = $row['id']; $dbto = $row['to']; $from = $row['from']; $heading = $row['heading']; $body = $row['body']; $dbdate = $row['date']; } $columns = array(); $data = array(); $xml = simplexml_load_file("test.xml"); echo $xml->getName() . "<br />"; foreach($xml->children() as $child) { echo $child->getName() . ": " . $child . "<br />"; $columns[] = $child->getName(); $data[] = (string)$child; } $col = '`'. implode('`,`',$columns) .'`'; $val = "'". implode("','",$data)."'"; if ($data[4]==$dbdate&&$dbto==$data[0]) die ("No need to update this record"); else { $query = "INSERT INTO rss ($col) VALUES ($val)"; mysql_query($query); echo "Record updated"; } ?> <?php echo "Hello"; ?> </p> </body> and this is what is outputted: note to: Tove from: Jani heading: Reminder body: Dont forget me this weekend! date: 2010-05-01 No need to update this record I'd be very greatful of anyhelp. Quote Link to comment https://forums.phpfreaks.com/topic/200441-what-have-i-done-to-stop-my-php-displaying-in-xammp/ Share on other sites More sharing options...
Mchl Posted May 2, 2010 Share Posted May 2, 2010 Start with steps described here: http://www.phpfreaks.com/tutorial/debugging-a-beginners-guide Quote Link to comment https://forums.phpfreaks.com/topic/200441-what-have-i-done-to-stop-my-php-displaying-in-xammp/#findComment-1051876 Share on other sites More sharing options...
newbtophp Posted May 2, 2010 Share Posted May 2, 2010 Benchmark your code. Quote Link to comment https://forums.phpfreaks.com/topic/200441-what-have-i-done-to-stop-my-php-displaying-in-xammp/#findComment-1051877 Share on other sites More sharing options...
vistar86 Posted May 2, 2010 Share Posted May 2, 2010 Try this: if ($data[4]==$dbdate&&$dbto==$data[0]) { echo "No need to update this record"; } See if it echos now, i'm presuming as you have told it to "Die" it will stop there and not follow on the seperate echo?? may be wrong, but i'm no pro either Quote Link to comment https://forums.phpfreaks.com/topic/200441-what-have-i-done-to-stop-my-php-displaying-in-xammp/#findComment-1051880 Share on other sites More sharing options...
Mchl Posted May 2, 2010 Share Posted May 2, 2010 Benchmark your code. Great idea. It doesn't work, so let's check how fast it doesn't work. Quote Link to comment https://forums.phpfreaks.com/topic/200441-what-have-i-done-to-stop-my-php-displaying-in-xammp/#findComment-1051922 Share on other sites More sharing options...
phpnewby1918 Posted May 3, 2010 Author Share Posted May 3, 2010 Thanks for your idea Vistar86 i tried it as you said and I thought it had worked. I needed to remove the mysql_close statement first because i was getting warning messages. It worked fine when the dates matched and there was no need to update... but... However, when the dates don't match and i need to update the database it updates it with TWO identical rows now. (I do appreciate your effort though) I can still run the "Hello" underneath it which i suppose it something. Quote Link to comment https://forums.phpfreaks.com/topic/200441-what-have-i-done-to-stop-my-php-displaying-in-xammp/#findComment-1052657 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.