Jump to content

Recommended Posts

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.

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 :)

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.