RE: Is my Hosting service full of it?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Beyond inspecting the posted code, are there any quality FREE tools that can
monitor MySQL resource usage? I searched Google using "mysql resource tools"
and came up with a number of tools, but all required payment.

I'm figuring that if you run a monitor while testing your code locally,
you'll be able to pinpoint precisely what causes the recources to be chewed
up.

Just a thought.

-----Original Message-----
From: pthes [mailto:peter@bizlogic.ca]
Sent: Sunday, February 09, 2003 11:42 AM
To: php-db@lists.php.net
Subject: Re:  Is my Hosting service full of it?


Thanks for the comments,. I'm putting some code here to hopefully get an
idea of what is considered inefficient when dealing with mysql. I'm confused
because all I'm doing is collecting the data from a form and writing it to
the db. I have about 30 pages in the survey, so a script similar to this is
called after each page.

<?php
session_start();

include("loginfile.inc");
$connection = mysql_connect($host,$user,$password)
       or die ("couldn't connect to server");
$db = mysql_select_db($database,$connection)
       or die ("Couldn't select database");

$intable = "tablename";

/* this is the duplicate check section */
$sql = "SELECT * FROM $intable WHERE datein = '$datein' AND itemID='$itemID'
";

$mysql_result = mysql_query($sql,$connection);
$num_rows = mysql_num_rows($mysql_result);

if ($num_rows == 0) {
/* insert if no dupes */
$query = "INSERT INTO itemsread (itemread,itemID,datein) VALUES
('$itemread','$itemID','$datein')";
$result = mysql_query($query);
}
else
{
/* update if existing timestamp */
$query = "UPDATE $intable SET itemread='$itemread' WHERE datein='$datein'
AND itemID='$itemID' ";
$result = mysql_query($query);
} # end else
mysql_close($connection);

It seems pretty simple to me. What am I missing?



--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux