0

That's all of my code and you can see at the end there's a die function can you tell me what I did wrong? It's this die function....

if(!$Query)
{
    die("There was an error creating your product!");
}
else
{
    echo "Yes! Your product was created I hope " . $Title . " will rank high!";
}
<?php

session_start();

$connect = mysql_connect("127.0.0.1","root","");
if (!$connect)
  {
  die("MySQL could not connect!");
  }

$DB = mysql_select_db('FinddOnline');

if(!$DB)
{
die("My SQL could not select Database!");
}

$Username = $_SESSION['username'];

if(empty($_SESSION['username']) || empty($_SESSION['password']))
{
    die("Go back and login before you visit this page!");
}
?>

<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body>

<div id="Wrapper">
<div id="Top">
<a href="index.php"> Home </a>
</div>

<div id="Body">

<img src="NewBigOnline.gif" alt="Findd Online" height="50" width="175" /></br>
</body>
</html>
<?php

//Variables
$Title = $_POST['title'];
$Category = $_POST['categories'];
$Price = $_POST['price'];
$url = $_POST['url'];
$SD = $_POST['shortdescription'];
$LD = $_POST['longdescription'];
$Tag1 = $_POST['tag1'];
$Tag2 = $_POST['tag2'];
$Tag3 = $_POST['tag3'];

if(empty($Title))
{
    die("You didn't enter a title!");
}

if($Category == "none")
{
    die("You need to select a category!");
}

if(empty($url))
{
    die("You didn't enter a url!");
}

if(empty($SD))
{
    die("You didn't enter a short description!");
}

if(strlen($SD) >= 200)
{
    die("Your Short description can be a maximum of 200 characters. yours is " . strlen($SD) . " characters.");
}

if(strlen($SD) <= 130)
{
    die("Your Short description can be a minimum of 130 characters. yours is " . strlen($SD) . " characters.");
}

if(empty($LD))
{
    die("You didn't enter a long description!");
}

if(strlen($LD) <= 350)
{
    die("Your Short description can be a minimum of 350 characters. yours is " . strlen($SD) . " characters.");
}

if(empty($Tag1))
{
    die("You didn't enter tag #1");
}

if(empty($Tag2))
{
    die("You didn't enter tag #2");
}

if(empty($Tag3))
{
    die("You didn't enter tag #3");
}

if(empty($Price))
{
    die("You never entered in a price for your product!");
}

//----------------------------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------------------

$Random_Number = rand(100,100000000000);
$Check_Number = mysql_query("SELECT * FROM products WHERE randomnumber='$Random_Number'");
$Check_Final = mysql_num_rows($Check_Number);

while($Check_Final != '0')
{
    $Random_Number = rand(100,100000000000);
}

$Query = mysql_query("INSERT INTO products (title,url,finalurl,category,owner,shortdescription,longdescription,price,rank,tag1,tag2,tag3)
                      VALUES ('$Title','$Random_Number','$url','$Category','$Username','$SD','$LD','$Price','0','$Tag1','$Tag2','$Tag3')");

if(!$Query)
{
    die("There was an error creating your product!");
}
else
{
    echo "Yes! Your product was created I hope " . $Title . " will rank high!";
}

$Create_File = fopen($Random_Number . '.php','w');
fwrite($Create_File,"
<?php

$Insert_Link_Click = mysql_query(\"INSERT INTO (username,title)
                      VALUES ('$Username','$Title')\");
if(!$Insert_Link_Click)
{
    die(\"Opps Try again!\");
}
else
{
header(\"location:$url\");
}
                      

?>
");

?>
<html>
<body>
</div>

<div id="Footer">
Footer
</div>
</div>

</body>
</html>
2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by nonshatter
0

So what's the error you're getting? Try this and report back with the error message:

$Query = mysql_query("INSERT INTO products (title, url, finalurl, category, owner, shortdescription, longdescription, price, rank, tag1, tag2, tag3) VALUES ('$Title','$Random_Number','$url','$Category','$Username','$SD','$LD','$Price','0','$Tag1','$Tag2','$Tag3')") or die(mysql_error());

echo "Yes! Your product was created I hope " . $Title . " will rank high!";

If there's a syntax error in the mysql statement, the code will stop executing (or die()). If there is no error, then it will echo the success message.

Edited by nonshatter: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.