Jump to content

double databasae connection errors


bruckerrlb

Recommended Posts

Hello all, I have been working on this script for the past 18 hours, and cannot seem to find the t-variable error, this is the code

 


<?php
// Always add these lines at the top of script
ini_set ('display_errors', 1);
error_reporting (E_ALL & ~E_NOTICE);

require_once('auth.php');

// Local Database connection
$local_db = mysql_connect('localhost','root');

mysql_select_db('users', $local_db);
// Remote Database connection
$remote_db = mysql_connect('192.168.1.2', 'gestion', '020508');
mysql_select_db('eisw', $remote_db);

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Seguimiento de llamadas</title>
<link href="style.css" rel="stylesheet" type="text/css" />
</head>

<body>

<div id="Layer2"></div>

<div class="main">

  <div class="header" style="text-align: center">
    <h1>Cabecera</h1>
  </div>

  <div class="toolbar">
    <span class="style2">Está Usten En: <a href="principle_menu_user.php" class="style2">Menú Principle</a></span> -
    <span class="style3">Seguimiento de llamadas</span>
  </div>

  <div class="userchooser" style="text-align: center">

    <form action="<?php echo $_SERVER['PHP_SELF']?>" method="post">
      <table>
        <tr>
          <td width="340" height="37">Seleccione el producto:</td>
          <td width="123">
            <select>

<?php
//if this causes errors, move the variable getting the session id somewhere else

$memberid = $_SESSION['SESS_MEMBER_ID'];

$query = "SELECT * FROM products WHERE clientid = '$memberid'";

$r = mysql_query($query, $local_db);
while ($row = mysql_fetch_array($r)) 

				{
		print '<option id="productname">' . $row['productname'] . '</option>\n';
						}

?>
            </select>
          </td>
        </tr>
        <tr>
          <td height="45">Llamadas realizadas los días:</td>
          <td><input type="text" id="startdate" name="startdate" /></td>
          <td width="108"><input type="text" id="enddate" name="enddate" /></td>
        </tr>
        <tr>
          <td height="41">Durante las horas:</td>
          <td><input type="text" id="starthour" name="starthour" /></td>
          <td><input type="text" id="endhour" name="endhour" /></td>
          <td><input type="submit" value="buscar" name="submit" /></td>
        </tr>
      </table>
    </form>

  </div>

<?php
// check that form has been submitted
// When the form is submitted the followng will be run.
if(isset($_POST['submit']))
{
?>
  <div class="datasectionuser">

    <table width="769">
      <tr bgcolor="#bbe0e3">
        <td width="141">Nº teléfono cliente</td>
        <td width="185">Nº teléfono en centralita</td>
        <td width="184">Producto asociado</td>
        <td width="34">fecha</td>
        <td width="80">hora</td>
        <td width="117">minutos</td>
      </tr>


<?php

$startdate = $_POST['startdate'];
$enddate = $_POST['enddate'];
$starthour = $_POST['starthour'];
$endhour = $_POST['endhour'];
$productname = $_POST['productname'];
$query = "SELECT * FROM products WHERE productname = '$productname'";





$r1 = mysql_query($query, $local_db);
list($productid) = mysql_fetch_array($r);
print "$productid";

	$query="SELECT * FROM ei10800010001200708 WHERE NumeroExterno = '". $productid . "' AND FechaDesde > ".$startdate."' AND FechaHasta < '".$enddate ."' AND HoraDesde > '".$starthour . "' AND HoraHasta < '". $endhour ."';";  

   
		[color=red]while ($row = mysql_fetch_array($r))
					{
[/color]?>
      <tr>
        <td width="141" align="center"> <?php echo "$row['NumeroExterno']"; ?></td>
        <td width="141" align="center"><?php echo "$row['NumeroExtension']"; ?></td>
        <td align="center"><?php  echo "$row['productname']"; ?></td>
        <td align="center"><?php  echo "$row['FechaDesde']"; ?></td>
        <td align="center"><?php echo "$row['HoraDesde']"; ?></td>
        <td align="center"><?php  echo "$row['Duracion']"; ?></td>
      </tr>
<?php
   }

?>
    </table>

    <!--I will Figure this export thing out if this query works-->
    <a href="excel.php" class="createnew">Exportar a Excel</a>

  </div>
<?php
} // close if
?>
</div>

</body>
</html>
<?php

// close connections to database
mysql_close($connect1);
mysql_close($connect2);

?>

 

The red is causing errors, I can't seem to find the problem anymore, i've triedrenaming variable names, and everything I possibly know, does anyone have any suggestions?

Link to comment
https://forums.phpfreaks.com/topic/63580-double-databasae-connection-errors/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.