Jump to content

Recommended Posts

information not posting into the database the code below is the check code/insert code. Please if anyone knows why let me know.

 

[color=red]<?php
//msut be logged in page
session_start();

if  ($_SESSION['username'])
{
echo"";
}
else
die("You must log in first!");

//form information
$submit = $_POST['submit'];
$row4 = $_SESSION['username'];

// form data
$link = strip_tags($_POST['link']);
$message = strip_tags($_POST['message']);
$title = strip_tags($_POST['title']);
$author = strip_tags($_POST['author']);
$date = date('Y-m-d');


$connect = mysql_connect("db","username","password") or die("Not connected");
mysql_select_db("username") or die("could not log in");
$querycheck = "SELECT * FROM boox WHERE username='$row4'";
$result = mysql_query($querycheck);
while($rowz = mysql_fetch_array($result))

$linkcheck = $rowz['link'];


if ($submit)
{
if($link&$title&$author)
{
	// check username and subject lentgh
	if ($linkcheck == $link)
	{
		die ("This link has already been posted.");
	}
	else

		{
			//open database
			$connect = mysql_connect("db","username","password") or die("Not connected");
			mysql_select_db("username") or die("could not log in");
			$queryreg = mysql_query("INSERT INTO boox Values ('','$row4','$link','$title','$author','$message','$date')");
			echo "You have just officialy posted on the Catalina Beat Mixers. ";

		}

}

}
		   
else
{
	die ("You forgot to put something in the link/title/author box.");
    }


?>[/color]
[code]

Link to comment
https://forums.phpfreaks.com/topic/248834-information-not-inserting-into-database/
Share on other sites

De-bugging added, please copy/paste the error that is printed to the screen.

<?php
//msut be logged in page
session_start();
//display all errors.
error_reporting(-1);
ini_set('display_errors',1);

if  ($_SESSION['username'])
{
echo"";
}
else
die("You must log in first!");

//form information
$submit = $_POST['submit'];
$row4 = $_SESSION['username'];

// form data
$link = strip_tags($_POST['link']);
$message = strip_tags($_POST['message']);
$title = strip_tags($_POST['title']);
$author = strip_tags($_POST['author']);
$date = date('Y-m-d');


$connect = mysql_connect("db","username","password") or die("Not connected");
mysql_select_db("username") or die("could not log in");
$querycheck = "SELECT * FROM boox WHERE username='$row4'";
$result = mysql_query($querycheck) or trigger_error(mysql_error()); //error trigger added.
while($rowz = mysql_fetch_array($result))

$linkcheck = $rowz['link'];


if ($submit)
{
if($link&$title&$author)
{
	// check username and subject lentgh
	if ($linkcheck == $link)
	{
		die ("This link has already been posted.");
	}
	else

		{
			//database is already open
			$queryreg = mysql_query("INSERT INTO boox Values ('','$row4','$link','$title','$author','$message','$date')") or trigger_error(mysql_error()); //added a error trigger on query failure.
			echo "You have just officialy posted on the Catalina Beat Mixers. ";

		}

}

}
		   
else
{
	die ("You forgot to put something in the link/title/author box.");
    }


?>
[code]

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.