Jump to content

Why do I get this error?


Kryllster

Recommended Posts

I get this error:

 

Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in C:\wamp\www\crimson\skill_comments.php on line 6

 

from this code:

<?php
// Define form variables and checks

$message = "Please do NOT leave any fields empty Thank You!!";
// Start the process of creation
	$skillname = $_POST['skillname'];
	$class = $_POST['class'];
	$type = $_POST['type'];
	$description = $_POST['description'];
	$name = $_POST['name'];

if (
    empty($_POST['skillname']) ||
    empty($_POST['class']) ||
    empty($_POST['type']) ||
    empty($_POST['description']) ||
    empty($_POST['name'])
  ) {
    echo $message;
    exit();
  }

// connection to database info here
$host = "localhost"; // Host name
$db_username = "rodan"; // Mysql username
$db_password = "yu5t1ll2"; // Mysql password
$db_name = "skillcomments"; // Database name
$tbl_name = "comments"; // Table name

// Connect to server and select databse.
$sql = mysql_connect("$host", "$db_username", "$db_password");

if (!$sql) {
    die('Could not connect: ' . mysql_error());
    exit();
}
else{
mysql_select_db("$db_name")or die("cannot select DB");
}

// Test for duplicate Username. If True then back to form. If not continue.
$sql = "select * from $tbl_name where skillname='" . $_POST['skillname'] . "'"; 
$result = mysql_query($sql);
if (mysql_num_rows($result) >= 1) { 
	echo "That Skillname is already taken please choose another!";
	exit();
	}

	else{
// Populate table from form and defined info
mysql_query("INSERT INTO $tbl_name (skillname, class, type, description, name) Values ('$skillname','$class','$type','$description','$name')");
}
?>

 

 

Some of this code is copy and paste from previous code that works I dont understand why its not working.

 

Thanks in advance,

Link to comment
https://forums.phpfreaks.com/topic/207278-why-do-i-get-this-error/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.