I have a PHP form that does several things:
1. Drop Down List
2. Radio Button
3. Depending on your selection from the DropDown List, an Insert of the data that matches that row in the lookup table will INSERT that data into another table.
When I ran each section separately it worked... but when I put it all together I get the following error:
Parse error: parse error in /var/www/htdocs/sna/batch3.php on line 27
Here is the code in question:
<?php
$ModelType = $_POST[‘ModelType’];
$Qty = $_POST[‘Qty’];
$OEMSku = $_POST[‘OEMSku’];
$Service = $_POST[‘Service’];
$con = mysql_connect("localhost","root","c0d3r3d!");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}mysql_select_db("snalogdata", $con);$sql="INSERT INTO snabatch (ModelType, OEMModel, ManfCode, $Qty, OEMSku, $Service)
SELECT * from 'ModelLookup' WHERE OEMSku = '$OEMSku';if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
echo "1 record added";mysql_close($sql,$con)
?>
The echo "1 record added";mysql_close($sql,$con) :Line is line 27 in question... but I cannot see where this is the problem area... it has to be somewhere else, but I have been looking at the code for so long it all looks right to me...
Any ideas would be great.
Texman
Weird Error - Cannot see what I'm doing wrong...
Moderator: General Moderators
-
texmansru47
- Forum Commoner
- Posts: 42
- Joined: Mon May 12, 2008 11:27 am
Re: Weird Error - Cannot see what I'm doing wrong...
Try this. Your SQL query is also incorrect, so you may have to change some things because I don't know what is supposed to insert into where. I just gave an example of how it works.
Code: Select all
<?php
$ModelType = mysql_real_escape_string($_POST[‘ModelType’]);
$Qty = mysql_real_escape_string($_POST[‘Qty’]);
$OEMSku = mysql_real_escape_string($_POST[‘OEMSku’]);
$Service = mysql_real_escape_string($_POST[‘Service’]);
$con = mysql_connect("localhost","root","c0d3r3d!") or die('Connection: ' . mysql_error());;
mysql_select_db("snalogdata", $con) or die('Database: ' mysql_error());
$sql="INSERT INTO snabatch (ModelType, OEMModel, ManfCode, OEMSku)
VALUES ('$ModelType', '$Service', '$Qty', '$Service')";
$result = mysql_query($sql,$con) or die('Query: ' . mysql_error());
if (!$result) {
echo 'error';
} else {
echo "1 record added";
}
mysql_close($sql,$con);
?>
-
texmansru47
- Forum Commoner
- Posts: 42
- Joined: Mon May 12, 2008 11:27 am
Re: Weird Error - Cannot see what I'm doing wrong...
Thanks.... I will try this. What I'm trying to do is - is to populate three fields of the snabatch database with data from a lookup table that will help eliminate some extra typing from the user, and provide a clean data upload. The query is to take the value from the initial screen for the OEMSku, the drop down list, and search by that. once the proper record is found, it will take those values of that record and insert them into snabatch into the correct fields. The other data is human entered since it will be specific to the data required for the batch creation for the order.
I will try your example and see what I get.
Thanks again.
Texman
I will try your example and see what I get.
Thanks again.
Texman
-
texmansru47
- Forum Commoner
- Posts: 42
- Joined: Mon May 12, 2008 11:27 am
Re: Weird Error - Cannot see what I'm doing wrong...
Well I tried it and I still cannot get any data to load into the database - snabatch... not even the posrt data from the form page. I know this is a big problem... but in my other less complex insertion pages, I have no problems... but I need these options in this form to eliminate human error.
So I cannot figure out what is going on... very weird.
Texman
So I cannot figure out what is going on... very weird.
Texman
Re: Weird Error - Cannot see what I'm doing wrong...
If you say the POST data isn't even working are you sure your fields are correctly named (case sensitive)
-
texmansru47
- Forum Commoner
- Posts: 42
- Joined: Mon May 12, 2008 11:27 am
Re: Weird Error - Cannot see what I'm doing wrong...
Actually I was monkeying with the code and I got it to work. I do appreciate your assistance... without it I would have been floundering.
Thanks again,
Texman
Thanks again,
Texman