Connecting Tech Pros Worldwide Forums | Help | Site Map

problem with mysqp

Newbie
 
Join Date: Oct 2008
Posts: 3
#1: Oct 1 '08
i wrote a php page to insert data into mysql database....first it seemed ok and was inserting currectly ..after inserting abt 10 to 12 rows inside the table in my database...it stopped inserting...(i am using WAMP)..So i tried to insert it by getting into the database (using the 'insert' option at the top) and it was working properly.If this is due to an error in my php page then how could i insert abt 10 to 12 rows without any problem???I tried every way i can by adding more no: of rows to show...but that too seemed useless!

Stang02GT's Avatar
Moderator
 
Join Date: Jun 2007
Location: USA
Posts: 1,152
#2: Oct 1 '08

re: problem with mysqp


Can you please post your code so we can get a better idea of what is going on. Also any error messages you are getting.
Newbie
 
Join Date: Oct 2008
Posts: 3
#3: Oct 3 '08

re: problem with mysqp


////////////////////////////home.php starts here///////////////////////////////////////////////////
<?php
$host="localhost";
$mysql_user="root";
$password="";
$database="library";
$link = @mysql_connect($host,$mysql_user,$password) or $conn="error";
@mysql_select_db($database,$link);
mysql_query("SET NAMES utf8");
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>

<script>
function show()
{
alert(document.getElementById('submit').value);
location.href='homeview.php';

}
function getthis(){
if(document.form.bkname.value=='')
{
alert('Please enter the name of the book');
document.form.bkname.focus();
return false;
}
if(document.form.bkauther.value=='')
{
alert('Please enter the name of the auther');
document.form.bkauther.focus();
return false;
}
if(document.form.bkprice.value=='')
{
alert('Please enter the cost of the book');
document.form.bkprice.focus();
return false;
}
if(document.getElementById('submit').value)
{
var n1 = document.getElementById('bkname').value;
var n2 = document.getElementById('bkauther').value;
var n3 = document.getElementById('bkprice').value;
var n4 = document.getElementById('bkava').selectedIndex;
var n5 = document.getElementById('bkava').options[n4].text;

//var n5 = document.getElementById.options[n4].value;
//alert(n4);
//location.href='hfirst1.php?display='+display.repla ce('&','%26')+'&chkbr='+chkbr;
location.href='homeentry.php?n1='+n1+'&n2='+n2+'&n 3='+n3+'&n5='+n5;
alert('You have successfully inserted!!!!');
}


//alert(document.getElementById('submit').value);
}

</script>
<head>

<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
.style1 {font-size: 24px}
-->
</style>
</head>


<body bgcolor="#000033">


<form method="post" name="form" action="">
<table width="1005" align="center"><tr><td colspan="5" bordercolor="#FFFFFF"><div align="left">
<h2><strong><span
style="font-size:xx-large; color:#FFFFFF;">Book Entry</span></strong></h2>
</div></td>
</tr>
<tr><td colspan="5">&nbsp;</td></tr>
<tr><td colspan="5">&nbsp;</td></tr>
<tr><td width="190">&nbsp;</td>
<td width="180">&nbsp;</td>
<td width="217">&nbsp;</td>
<td width="153">&nbsp;</td>
<td width="241"><a href="homeview.php"><img src="btn_view.gif" width="85" height="24" border="0" /></a></td>
</tr>
<tr><td colspan="5">&nbsp;</td>
</tr></table>
<table width="457" height="228" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#CCCCCC">
<tr>
<td width="164" height="47"> <div align="center" class="style1">Book Name </div></td>
<td width="293"><div align="center"><input type="text" name="bkname" size="40" id="bkname" value="<?php echo $bkname?>"></div></td>
</tr>
<tr>
<td><div align="center" class="style1">Auther</div></td>
<td><div align="center"><input type="text" name="bkauther" size="40" id="bkauther" value="<?php echo $bkauther?>"></div></td>
</tr>
<tr>
<td><div align="center" class="style1">Price</div></td>
<td><div align="center"><input type="text" name="bkprice" size="40" id="bkprice" value="<?php echo $bkprice?>"></div></td>
</tr>
<tr>
<td height="44"><div align="center" class="style1">Available</div></td>
<!-- <td><div align="center"><input type="text" name="bkava" id="bkava" value=""></div></td> -->
<td><div align="center"><select name="bkava" size="1" id="bkava">
<option selected>yes</option>
<option>no</option>
</select>

</div></td>
</tr>
<tr>
<td><div align="center"></div></td>
<td><div align="center"><input type="submit" name="submit" value="save" id="submit" onClick="return getthis()"></div></td>
</tr>
</table>
<div align="left"></div>
</form>

</body>
</html>

///////////////////////////////home.php ends here/////////////////////////////////////

///////////////////homeentry.php starts here///////////////////////////////////
<?php
$host="localhost";
$mysql_user="root";
$password="";
$database="library";
$link = @mysql_connect($host,$mysql_user,$password) or $conn="error";
@mysql_select_db($database,$link);
mysql_query("SET NAMES utf8");
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<?php
$n1=$_REQUEST["n1"];
$n2=$_REQUEST["n2"];
$n3=$_REQUEST["n3"];
$n5=$_REQUEST["n5"];

//$sql= mysql_query("insert into bk_entry(bkname,bkauther,costofbk,available) values('$n1','$n2','$n3','$n5')");
$sql=mysql_query("INSERT INTO library.bk_entry (bkname, bkauther, costofbk, available) VALUES ('$n1', '$n2', '$n3', '$n5');");
?>
</body>
</html>

/////////////////////////////ends here/////////////////////////////////////////////
Newbie
 
Join Date: Oct 2008
Posts: 3
#4: Oct 3 '08

re: problem with mysqp


Quote:

Originally Posted by Stang02GT

Can you please post your code so we can get a better idea of what is going on. Also any error messages you are getting.

.....the most interesting thing is ....i don't have any error msg!!!!!!!!!!!!!!!!!!!!
Reply