Jump to content

Whats The Correct Way To Write This... !? please pretty simple code


jigsawsoul

Recommended Posts

Using the above code give me these errors;

Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /home/jigsaws2/public_html/tape/add2.php on line 33

Parse error: syntax error, unexpected T_STRING in /home/jigsaws2/public_html/tape/add2.php on line 33

 

 

<?php session_start(); 

$message .= $_SESSION["message"];

include('_resources/opendb.php');

$_SESSION['message'] = "";

if (empty($_POST['use']))
            $_SESSION['message'] .= "<font color=red><li>You must submit in an idea.<br /></li></font>";

    if (!empty($_SESSION['message'])) {
    		$_SESSION['message'] .= "<br />";
            header("Location: add.php");
            exit();
     }

$use = mysql_real_escape_string($_POST['use']);

$use = ucwords($use);

$query = "INSERT INTO uses (uses) VALUES ('$use')";

if (mysql_query ($query)) {
	$id = mysql_insert_id();
} 
else {
		$_SESSION['message'] = "<font color=red><li>Couldnt Add 1</li><br /></font>";
		header('Location: add.php');
	}


$js = '$(\'#' . $id . ').tipsy({gravity: '\n\'});';
$query = "INSERT INTO `uses` (`js`) VALUES ('$js') WHERE `id` = '$id'";

if (mysql_query ($query)) {
	$_SESSION['message'] = "<font color=green><li>Your idea was added below</li><br /></font>";
	header('Location: index.php');
} 
else {
		$_SESSION['message'] = "<font color=red><li>Couldnt Add 2</li><br /></font>";
		header('Location: add.php');
	}

include('_resources/closedb.php'); ?>

Link to comment
Share on other sites

$js = "$('#" . $id . "').tipsy({gravity: 'n'});";
$query = "INSERT INTO `uses` (`js`) VALUES ('$js') WHERE `id` = '$id'";
if (mysql_query ($query)) {
$_SESSION['message'] = "<font color=green><li>Your idea was added below</li><br /></font>";
header('Location: index.php');
} else {
exit(print(mysql_error()));
$_SESSION['message'] = "<font color=red><li>Couldnt Add 2</li><br /></font>";
header('Location: add.php');
}

 

Post what the error is.

 

James.

Link to comment
Share on other sites

$js = "\$('#" . $id . "').tipsy({gravity: 'n'});";
$query = "INSERT INTO `uses` (`js`) VALUES ('$js') WHERE `id` = '$id'";
if (mysql_query ($query)) {
$_SESSION['message'] = "<font color=green><li>Your idea was added below</li><br /></font>";
header('Location: index.php');
} else {
exit(print(mysql_error()));
$_SESSION['message'] = "<font color=red><li>Couldnt Add 2</li><br /></font>";
header('Location: add.php');
}

 

James.

Link to comment
Share on other sites

i replaced $js with

$js = '\$(\'#' . $id . '\').tipsy({gravity: \'n\'});';

 

and had the error message

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE `id` = '23'' at line 1

 

does this help?

 

Link to comment
Share on other sites

much love  :D

<?php session_start(); 

$message .= $_SESSION["message"];

include('_resources/opendb.php');

$_SESSION['message'] = "";

if (empty($_POST['use']))
            $_SESSION['message'] .= "<font color=red><li>You must submit in an idea.<br /></li></font>";

    if (!empty($_SESSION['message'])) {
    		$_SESSION['message'] .= "<br />";
            header("Location: add.php");
            exit();
     }

$use = mysql_real_escape_string($_POST['use']);

$use = ucwords($use);

$query = "INSERT INTO uses (uses) VALUES ('$use')";

if (mysql_query ($query)) {
	$id = mysql_insert_id();
} 
else {
		$_SESSION['message'] = "<font color=red><li>Couldnt Add 1</li><br /></font>";
		header('Location: add.php');
	}

$js = '1';
$query = "INSERT INTO `uses` (`js`) VALUES ('$js') WHERE `id` = '$id'";
if (mysql_query ($query)) {
$_SESSION['message'] = "<font color=green><li>Your idea was added below</li><br /></font>";
header('Location: index.php');
} else {
exit(print(mysql_error()));
$_SESSION['message'] = "<font color=red><li>Couldnt Add 2</li><br /></font>";
header('Location: add.php');
}
include('_resources/closedb.php'); ?>

 

Link to comment
Share on other sites

includes the right $js

 

<?php session_start(); 

$message .= $_SESSION["message"];

include('_resources/opendb.php');

$_SESSION['message'] = "";

if (empty($_POST['use']))
            $_SESSION['message'] .= "<font color=red><li>You must submit in an idea.<br /></li></font>";

    if (!empty($_SESSION['message'])) {
    		$_SESSION['message'] .= "<br />";
            header("Location: add.php");
            exit();
     }

$use = mysql_real_escape_string($_POST['use']);

$use = ucwords($use);

$query = "INSERT INTO uses (uses) VALUES ('$use')";

if (mysql_query ($query)) {
	$id = mysql_insert_id();
} 
else {
		$_SESSION['message'] = "<font color=red><li>Couldnt Add 1</li><br /></font>";
		header('Location: add.php');
	}

$js = '\$(\'#' . $id . '\').tipsy({gravity: \'n\'});';
$query = "INSERT INTO `uses` (`js`) VALUES ('$js') WHERE `id` = '$id'";
if (mysql_query ($query)) {
$_SESSION['message'] = "<font color=green><li>Your idea was added below</li><br /></font>";
header('Location: index.php');
} else {
exit(print(mysql_error()));
$_SESSION['message'] = "<font color=red><li>Couldnt Add 2</li><br /></font>";
header('Location: add.php');
}
include('_resources/closedb.php'); ?>

Link to comment
Share on other sites

Ok first problem, you have set $js to 1?

 

<?php session_start(); 

$message .= $_SESSION["message"];

include('_resources/opendb.php');

$_SESSION['message'] = "";

if (empty($_POST['use']))
            $_SESSION['message'] .= "<font color=red><li>You must submit in an idea.<br /></li></font>";

    if (!empty($_SESSION['message'])) {

$_SESSION['message'] .= "<br />";
            header("Location: add.php");
            exit();
     }

$use = mysql_real_escape_string(ucwords($_POST['use']));

$query = "INSERT INTO `uses` (`uses`) VALUES('$use')";

if (mysql_query($query)) {

$id = mysql_insert_id();

} else {

$_SESSION['message'] = "<font color=red><li>Couldnt Add 1</li><br /></font>";
header('Location: add.php');

}

$js = '\$(\'#' . $id . '\').tipsy({gravity: \'n\'});';
$query_t = "INSERT INTO `uses` (`js`) VALUES ('$js')";
if (mysql_query($query_t)) {
$_SESSION['message'] = "<font color=green><li>Your idea was added below</li><br /></font>";
header('Location: index.php');
} else {
exit(print(mysql_error()));
$_SESSION['message'] = "<font color=red><li>Couldnt Add 2</li><br /></font>";
header('Location: add.php');
}
include('_resources/closedb.php');
?>

 

James.

Link to comment
Share on other sites

Everything above the exit(); is fine and works great.  :shrug:

 

<?php session_start(); 

$message .= $_SESSION["message"];

include('_resources/opendb.php');

$_SESSION['message'] = "";

if (empty($_POST['use']))
            $_SESSION['message'] .= "<font color=red><li>You must submit in an idea.<br /></li></font>";

    if (!empty($_SESSION['message'])) {

$_SESSION['message'] .= "<br />";
            header("Location: add.php");
            exit();
     }

$use = mysql_real_escape_string(ucwords($_POST['use']));

$query = "INSERT INTO `uses` (`uses`) VALUES('$use')";

if (mysql_query($query)) {

$id = mysql_insert_id();

} else {

$_SESSION['message'] = "<font color=red><li>Couldnt Add 1</li><br /></font>";
header('Location: add.php');

}

exit();

$js = '\$(\'#' . $id . '\').tipsy({gravity: \'n\'});';


$query_t = "INSERT INTO `uses` (`js`) VALUES ('$js')";
if (mysql_query($query_t)) {
$_SESSION['message'] = "<font color=green><li>Your idea was added below</li><br /></font>";
header('Location: index.php');
} else {
exit(print(mysql_error()));
$_SESSION['message'] = "<font color=red><li>Couldnt Add 2</li><br /></font>";
header('Location: add.php');
}
include('_resources/closedb.php');
?>

Link to comment
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.