*New error* data from form to mysql help please

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
mikegotnaild
Forum Contributor
Posts: 173
Joined: Sat Feb 14, 2004 5:59 pm

*New error* data from form to mysql help please

Post by mikegotnaild »

I get "Parse error: parse error in /www/n/naild/htdocs/localmm/modules/Band_List/submit.php on line 23"
And i dont understand why. Heres my code for both the form and the action.

submitaband.php

Code: Select all

<? 
if(!eregi("modules.php", $_SERVER&#1111;'PHP_SELF']))&#123; 
     die("You can't access this file directly..."); 
&#125; 

$module_name = basename(dirname(__FILE__)); 
$module_dir = "modules/$module_name/"; 
include("header.php"); 
$index = 1;//right sidebar or not 0=off 1=on 
title("Submit a band"); 
OpenTable(); 
?> 

<FORM ACTION="http://naild.com/localmm/modules.php?name=Band_List&file=submit" METHOD="POST"> 
Band Name:<br>
<input type="text" name="band_name"size=20><br>
Description:<br>
<textarea cols=65 rows=10 name="description"></textarea><br>
History:<br>
<textarea cols=65 rows=10 name="history"></textarea><br> 
Influences:<br>
<input type="text" name="influences"size=65><br>
Select Genra:<br>
<select name="genra" size=20 multiple><br>
<option>Acoustic 
<option>Alternative 
<option>Blues 
<option>Christian 
<option>Classic Rock 
<option>Classical 
<option>Country 
<option>Cover Bands 
<option>Death Metal 
<option>Disc Jockey 
<option>Easy Listening 
<option>Electronic 
<option>Emo 
<option>Experimental 
<option>Folk 
<option>Funk 
<option>Gospel 
<option>Gothic 
<option>Grunge 
<option>Hardcore 
<option>Hip Hop 
<option>Instrumental 
<option>Jazz 
<option>Metal 
<option>Modern Rock 
<option>Progressive 
<option>Punk 
<option>Rap 
<option>Reggae 
<option>Rock 
<option>Speed Metal 
<option>Swing 
<option>Techno 
</select>
<br> 
   Email:<br>
   <input type="text" name="email"size=20><br>
   Website:<br>
   <input type="text" name="website"size=20><br>
   <input type="submit" name="submit" value="submit">
</form>
<?php 
CloseTable(); 
include("footer.php"); 
?>
Submit.php

Code: Select all

<?
//MySQL Variables
$host = "host";
$login_name = "user";
$password = "pass";

//Connecting to MYSQL
MySQL_connect("$host","$login_name","$password");

//Select the database
MySQL_select_db("bandsandmembers") or die("Could not select database");

//Assign contents of form to variables
$bandname = $_POST&#1111;'band_name']; 
$description = $_POST&#1111;'description'];
$history = $_POST&#1111;'history'];
$influences = $_POST&#1111;'influences'];
$genra = $_POST&#1111;'genra'];
$email = $_POST&#1111;'email'];
$website = $_POST&#1111;'website'];

$sql = "INSERT INTO nuke_bands FROM bandsandmembers SET
band_name = "$bandname", // THIS IS LINE 23
description = "$description"
history = "$history"
influences = "$influences"
genra = "$genra"
Email = "$email"
website = "$website"
"); 

$result = mysql_query($sql);

//Code to check if statement executed properly and display a page
if ($result) &#123;
header("Location: http://naild.com/localmm/modules.php?name=Band_List&file=sent");
&#125; else &#123;
echo("An error has occured");
&#125;
//Close connection with MySQL
MySQL_close()
?>
Last edited by mikegotnaild on Mon Feb 16, 2004 3:24 am, edited 2 times in total.
microthick
Forum Regular
Posts: 543
Joined: Wed Sep 24, 2003 2:15 pm
Location: Vancouver, BC

Post by microthick »

Code: Select all

//Select the database 
MySQL_select_db("bandsandmembers") or die("Could not select database" 

//Assign contents of form to variables 
$bandname = $_POST&#1111;'band_name']; // THIS IS LINE 14
Missing semi-colon on line 12... where you are selecting the database.
mikegotnaild
Forum Contributor
Posts: 173
Joined: Sat Feb 14, 2004 5:59 pm

Post by mikegotnaild »

Now im getting a new error on line 23
mikegotnaild
Forum Contributor
Posts: 173
Joined: Sat Feb 14, 2004 5:59 pm

Post by mikegotnaild »

Should i be doing this

Code: Select all

$sql = "INSERT INTO nuke_bands FROM bandsandmembers (band_name, description, history, influences, genra, Email, website) VALUES ('$bandname','$description','$history','$influences','$genra','#email','$website')");
mikegotnaild
Forum Contributor
Posts: 173
Joined: Sat Feb 14, 2004 5:59 pm

Post by mikegotnaild »

That doesnt work either
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

sql = "INSERT INTO nuke_bands (band_name, description, history, influences, genra, Email, website) VALUES ('$bandname','$description','$history','$influences','$genra','$email','$website')";

Not sure what the 'FROM bandsandmembers' bit was trying to do :o
mikegotnaild
Forum Contributor
Posts: 173
Joined: Sat Feb 14, 2004 5:59 pm

Post by mikegotnaild »

lol DUH!
mikegotnaild
Forum Contributor
Posts: 173
Joined: Sat Feb 14, 2004 5:59 pm

Post by mikegotnaild »

im still getting an error on that line though

$sql = "INSERT INTO nuke_bands (band_name, description, history, influences, genra, Email, website) VALUES ('$bandname','$description','$history','$influences','$genra','$email','$website')";
mikegotnaild
Forum Contributor
Posts: 173
Joined: Sat Feb 14, 2004 5:59 pm

Post by mikegotnaild »

nevermind i had an e xtra )
mikegotnaild
Forum Contributor
Posts: 173
Joined: Sat Feb 14, 2004 5:59 pm

Post by mikegotnaild »

YAY my FIRST working data submission into mysql!
mikegotnaild
Forum Contributor
Posts: 173
Joined: Sat Feb 14, 2004 5:59 pm

Post by mikegotnaild »

i got ONE tiny problem with this. When i test my form and submit it. All information is recorded correctly to the database Except for email. In phpmyadmin under the Column Email. It shows #Email and not the correct information. What is making this happen?
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

Cause you left in the #email (in the INSERT query) instead of $email as i'd corrected? ;)
Post Reply