Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.