Jump to content


Photo

INSERT query running twice through PHP page?


  • Please log in to reply
2 replies to this topic

#1 kittiiekat

kittiiekat
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 28 April 2006 - 08:51 PM

I'm baffled. I'm trying to run an INSERT query via a PHP page and the query appears to be running twice. I went through the page and commented out various sections until I isolated the line that would appear to be causing the problem... but it doesn't make any sense to me. The line in question is this:

<img src="<?php echo $row[image]; ?>">

If $row[image] has a value, there is no problem. However, if it is NULL or the value is blank, the row is inserted into the database twice. Can anybody explain to me why this would happen? Thanks :)

#2 milesperhour1086

milesperhour1086
  • Members
  • PipPip
  • Member
  • 12 posts

Posted 28 April 2006 - 08:56 PM

post some code
Micah[br] --PHP Newbie

#3 kittiiekat

kittiiekat
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 28 April 2006 - 09:02 PM

It doesn't matter what the INSERT query I run is, every one I try behaves as expected if I run it directly from terminal in mysql or if $row[image] has a value. I've tried running a test using a very basic page and I get the same problem. The entire code for the page is as follows:



<?php


$conn = @mysql_connect('localhost', 'user', 'password');
if (!$conn) {
echo '<p><b>error:</b> cannot connect to server</p>';
exit();
}

if (!@mysql_select_db('database')) {
exit('<p><b>error:</b> could not locate database</p>');
}


mysql_query("INSERT INTO test VALUES ('2', 'my name')");


?>

<html>
<body>

<img src="">

</body>
</html>



If I use <img src="">, I get the insert entered twice. If I use <img src="asdf">, it works fine.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users