Jump to content

Recommended Posts

<?php
session_start();
include("connect.php");

error_reporting(E_ALL);
ini_set('display_errors', '1'); 

   $username = "Master";
$password = "pword";
$host = "localhost";
$database = "Ustack";

// Make the connect to MySQL or die
// and display an error.
$link = mysql_connect($host, $username, $password);
if (!$link) {
    die('Could not connect: ' . mysql_error());
}

// Select your database
mysql_select_db ($database); 
$url = mysql_real_escape_string($_POST['url']);
$tags = get_meta_tags($url);

  $username1 = $_SESSION['username'];
  $url = mysql_real_escape_string($_POST['url']);
  $name = mysql_real_escape_string($_POST['title']);
  $description = $tags['description'];    
  $keywords = $tags['keywords'];
  $ip = $_SERVER['REMOTE_ADDR'];



$query = "INSERT INTO Stacks";
      $query .= "(`username`,`hyperlink`,`name`,`summary`,`info`,`keywords`,`ip`,`posted`) VALUES ('$username1','$url','$name','$description','$description','$keywords','$ip',NOW())";
      $results = mysql_query($query, $link);
  
  if($query){ 
  
  


print "<br><font color=white>Your webpage has been stacked.  <a href='menu.php'>Return to Stacker</a></font>"; }
else {
print "No url selected/uploaded";
}


      


// Close our MySQL Link
mysql_close($link);  

?>

 

its not inserting into mysql, i get no errors... whats the problem? 

Link to comment
https://forums.phpfreaks.com/topic/179442-i-have-no-idea-why-this-isnt-working/
Share on other sites

probably would help if you echoed the mysql query (with an or die or something)

 

but it seems that this

$query = "INSERT INTO Stacks";
      $query .= "(`username`,`hyperlink`,`name`,`summary`,`info`,`keywords`,`ip`,`posted`) VALUES ('$username1','$url','$name','$description','$description','$keywords','$ip',NOW())";

would create a string that looked like

$query = "INSERT INTO Stacks(`username`,`hyperlink`,`name`,`summary`,`info`,`keywords`,`ip`,`posted`) VALUES ('$username1','$url','$name','$description','$description','$keywords','$ip',NOW())";

 

you may want to put a space between Stacks and the parentheses.

$query = "INSERT INTO Stacks ";
      $query .= "(`username`,`hyperlink`,`name`,`summary`,`info`,`keywords`,`ip`,`posted`) VALUES ('$username1','$url','$name','$description','$description','$keywords','$ip',NOW())";
      $results = mysql_query($query, $link);
     
     if($results){ 

 

Basically what mikesta707 said, added a fix to your if statement; replaced $query with $results. 

there seems to be a problem with description and keywords. i am getting the result "no url selected/uploaded"..its not inserting into mysql.

 

so the problem is with $description and $keywords because i tested everything else, when these two are added it doesn't insert.

lol i can't spot what is wrong!

 

   $username = "Master";
$password = "pword";
$host = "localhost";
$database = "Ustack";

// Make the connect to MySQL or die
// and display an error.
$link = mysql_connect($host, $username, $password);
if (!$link) {
    die('Could not connect: ' . mysql_error());
}

// Select your database
mysql_select_db ($database); 



  
  
  
  
$url = mysql_real_escape_string($_POST['url']);
  $tags = get_meta_tags($url);
  
$description = $tags['description'];    
  $keywords = $tags['keywords'];
  $ip = $_SERVER['REMOTE_ADDR'];



$query = "INSERT INTO Stacks (`info`,`keywords`,`ip`,`posted`) VALUES ('$description','$keywords','$ip',NOW())"  or die (mysql_error());


      $results = mysql_query($query, $link);
  
  if($results){ 
  
  


print "<br><font color=white>Your webpage has been stacked.  <a href='menu.php'>Return to Stacker</a></font>"; }
else {
print "No url selected/uploaded";
}


      


// Close our MySQL Link
mysql_close($link);  

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.