jsbert
06-12-2009, 06:22 PM
I've been busting my head looking a this simple code and I can't find why I keep on getting a warning that stops the form from displaying, although it inserts the query in the DB fine? I guess I need a pair of fresh eyes, Before hand thank you much.
<?php // This Php Script actually inserts the info & shows its results.
$con = mysql_connect("localhost","root");
if (!$con) { die('Could not connect: ' . mysql_error()); }
mysql_select_db("lab", $con);
//foreach ($_POST as $field => $value){ echo $field. ' = ' .$value. '<br>'; }
$query = "INSERT INTO lab.ambulatorio (id, date, billNum, client, amount)
VALUES ('$_POST[id]', '$_POST[date]', '$_POST[billNum]', '$_POST[client]', '$_POST[amount]')";
//echo $query;
$result = mysql_query($query);
include("outPatientResults.ini");
while(@$row = mysql_fetch_array($result)){
include("outPatientResults.ini");
}
//$result = mysql_query($query,$con);
//$nrows=mysql_num_rows($result);
mysql_close($con);
?>
------------------------------------------------------
OUTPUT
id = 6
date = 2009-06-10
billNum = 00405
firstName = María
lastName = Rincón
client =
amount = 75
submit = Enviar
INSERT INTO lab.ambulatorio (id, date, billNum, client, amount) VALUES (' 6 ', '2009-06-10', '00405', '', '75')
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\xampp\htdocs\Muestrario\demo\outPatientResults.php on line 21
-------------------------------------------------------------
DB TYPES
id int, date date, billNum int, client string, amount int
<?php // This Php Script actually inserts the info & shows its results.
$con = mysql_connect("localhost","root");
if (!$con) { die('Could not connect: ' . mysql_error()); }
mysql_select_db("lab", $con);
//foreach ($_POST as $field => $value){ echo $field. ' = ' .$value. '<br>'; }
$query = "INSERT INTO lab.ambulatorio (id, date, billNum, client, amount)
VALUES ('$_POST[id]', '$_POST[date]', '$_POST[billNum]', '$_POST[client]', '$_POST[amount]')";
//echo $query;
$result = mysql_query($query);
include("outPatientResults.ini");
while(@$row = mysql_fetch_array($result)){
include("outPatientResults.ini");
}
//$result = mysql_query($query,$con);
//$nrows=mysql_num_rows($result);
mysql_close($con);
?>
------------------------------------------------------
OUTPUT
id = 6
date = 2009-06-10
billNum = 00405
firstName = María
lastName = Rincón
client =
amount = 75
submit = Enviar
INSERT INTO lab.ambulatorio (id, date, billNum, client, amount) VALUES (' 6 ', '2009-06-10', '00405', '', '75')
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\xampp\htdocs\Muestrario\demo\outPatientResults.php on line 21
-------------------------------------------------------------
DB TYPES
id int, date date, billNum int, client string, amount int