thank

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
madu
Forum Commoner
Posts: 32
Joined: Sat Dec 25, 2010 3:19 am
Location: india

thank

Post by madu »

hi friends....
Finally i finished my work with all urs help,,,thaks a lot,,,,, now the problem is ,,, i run this code in MAMP it runs perfectlyy,,,but when i am try to run this code in WAMP it shows error message(You have error on sql syntax near ')

Code: Select all

<html>
<body>
<?php
session_start() or die("errror");
include "tacre.php";
$da= "show tables";
$ds=mysql_query($da) or die("Error While retreiving tables". mysql_error());
$t=0;
$dar=array();

while($er=mysql_fetch_assoc($ds))
{
//print $er['Tables_in_gm']."<br>";
$dar[$t]=$er['Tables_in_gm'];
$t++;
}
echo "<br>";
echo '<form name=for method=get action="nload.php">';
echo  'Enter the user name:&nbsp<input type=text name=uname style="position:absolute;left:160px"><br><br>
Enter the mail id:&nbsp<input type=text name=eid style="position:absolute;left:160px"> <br>
<br>';
echo "Select the group you want to add =>";
echo '<select id=ty name=group onChange="show();">';
echo "<OPTION > None</option>";
foreach ($dar as $key => $value)
{
echo "<OPTION value='".$value."'> $value</option>";

}
echo "</select>";
echo '<input type=submit name=but style="position:absolute;left:140px;top:150px" value=Add><br>';
echo '</form>';


$rt=trim((String)'<script language=javascript>
function show()
{
var show=document.getElementById("ty").options[document.getElementById("ty").selectedIndex].value;
document.write(show);
}
</script>');
//$_SESSION['tab']= $rt;
//echo $rt;
$un=$_GET['uname'];
$e=$_GET['eid'];
$w=$_GET['group'];

if(isset($_GET[but]))
 {
$sql="insert into $w values ('".$un."','".$e."')";
if(mysql_query($sql,$con) or die("<br>error in insertion ".mysql_error()))
echo "Successfully Added";
}
?>
<br>
<a href="home.php">Goto home page</a>
</body>
</html>
User avatar
Jade
Forum Regular
Posts: 908
Joined: Sun Dec 29, 2002 5:40 pm
Location: VA

Re: thank

Post by Jade »

Make sure you've uploaded your include file and that you have a working database connection.
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

Re: thank

Post by social_experiment »

In which line is the error? There is a problem with your query

Code: Select all

<?php $sql="insert into $w values ('".$un."','".$e."')"; ?>
The correct syntax to insert looks like INSERT into table (field, field1) VALUES (value, value1)
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
Post Reply