Jump to content

MrXHellboy

Members
  • Posts

    153
  • Joined

  • Last visited

    Never

Posts posted by MrXHellboy

  1. This is your loop,

     

    The rest is up to you....

     

    <?php
    
    // Pick the amount
    $UploadAmount = $_POST['amount'];
    
    function check_input($value)
    {
    // Stripslashes
    if (get_magic_quotes_gpc())
      {
      $value = stripslashes($value);
      }
    // Quote if not a number
    if (!is_numeric($value))
      {
      $value = "'" . mysql_real_escape_string($value) . "'";
      }
    return $value;
    }
    
    $_POST = array_map('check_input', $_POST);
    
    // This is your loop, will run een x amount of time, depending on $UploadAmount
    for ($x = 0; $x < $UploadAmount; $x++)
    {
    $sql="INSERT INTO testimonials (CustomerName, Town, Testimonial, SortOrder, Images)
    VALUES
    ({$_POST['customername']}, {$_POST['town']}, {$_POST['testimonial']}, {$_POST['sort_order']}, '$imgname'
    
    )";
    }
    
    }
    if (!mysql_query($sql,$con))
      {
      die("<br>Query: $sql<br>Error: " . mysql_error() . '<br>');
      }
    echo "<p align=center><b>1 testimonial added</b></p>";
    
    mysql_close($con);
    ?>
    

  2. As far as i know, header('Content-Type: image/png'); and HTML output wont go together...... Unless you want to do difficult stuff... But you have to use google for that.... This is not i know for sure, but i assume you can't use html output with content-type image/png

  3. Your syntax error should be gone

    <?php
    $query1 = "SELECT * FROM members WHERE rsUser = '".$rsUser."' AND rsPass = '".$rsPass."'";
    $result1 = mysql_query($query1);
    $row1 = mysql_fetch_array($result1);
    
    
    $_SESSION['USERID']=row1['USERID'];
    $_SESSION['RSPOSTCODE']=row1['RSPOSTCODE'];
    $_SESSION['RSEMAIL']=row1['RSEMAIL'];
    $_SESSION['RSUSER']=row1['RSUSER'];
    
    $pSQL = "INSERT INTO favepub_COPY (USERID,PUBID)"
    $pSQL = $pSQL."SELECT ".$_SESSION["USERID"].", PUBID "
    $pSQL = $pSQL."FROM pubs "
    $pSQL = $pSQL."WHERE left(rsPostCode,4) = '".$_SESSION["RSPOSTCODE"]."'"
    ?>
    

     

     

  4. <?php
    $conn = mysql_connect("localhost","myusername","thepassword1");
    mysql_select_db("mydataB", $conn);
    
    // Escape special characters
    $username = mysql_real_escape_string($_POST['username'], $conn);
    // Then use the escaped $username
    $result = mysql_query("SELECT * FROM applicant WHERE username = '$username'");
    
    if (mysql_num_rows($result) > 0){
    $register = "&err=Not Available.";
    echo($register);
    } else {
    $username = mysql_real_escape_string($_POST['username'], $conn);
    $password = mysql_real_escape_string($_POST['password'], $conn);
    $name = mysql_real_escape_string($_POST['name'], $conn);
    $email = mysql_real_escape_string($_POST['email'], $conn);
    $id = mysql_real_escape_string($_POST['id'], $conn);
    
    mysql_query("INSERT INTO applicant (username, password, name, email, id) VALUES ('$username', '$password', '$name', '$email', '$id')");
    $register = "Successful.";
    echo($register);
    }
    ?>
    

  5. I am absolutely not sure what you want, but this removes the whole thing.

     

    
    <?php
    error_reporting(E_ALL);
    
    $a = "<sup class='footnote' value='[<a href=\"XXX\" title=\"See footnote XXX\">XXX</a>]'>[<a href=\"XXX\" title=\"See footnote XXX\">XXX</a>]</sup>";
    
    echo preg_replace('@<sup (.*)>(.*)<\/sup>@', '', $a);
    
    ?>
    

     

    If this is not what you want, please correct me and show me a example of how it must be!

  6. For the } else { // real escapre string } part it is ok.

     

    But after the mysql_select_db(), you have $username not escaped.

    <?php
    $conn = mysql_connect("localhost","myusername","thepassword1");
    mysql_select_db("mydataB", $db);
    
    // Escape special characters
    $username = mysql_real_escape_string($_POST['username'], $db);
    // Then use the escaped $username
    $result = mysql_query("SELECT * FROM applicant WHERE username = '$username'");
    
    if (mysql_num_rows ($result) > 0){
    $register = "&err=Not Available.";
    echo($register);
    } else {
    $username = mysql_real_escape_string($_POST['username'], $db);
    $password = mysql_real_escape_string($_POST['password'], $db);
    $name = mysql_real_escape_string($_POST['name'], $db);
    $email = mysql_real_escape_string($_POST['email'], $db);
    $id = mysql_real_escape_string($_POST['id'], $db);
    
    mysql_query("INSERT INTO applicant (username, password, name, email, id) VALUES ('$username', '$password', '$name', '$email', '$id')");
    $register = "Successful.";
    echo($register);
    }
    ?>
    

     

    Besides that, the link identiefier would be $conn here, i dont know why you are using $db as link ID.

  7. I meant the first piece of code. . . . My bad...

     

    However, i checked again the mysql manual, but according to them, you would be able to use the LIMIT outside the parentheses. I've tried those, i even tried to perform it on a very small table with just 2 fields but still the same result.

  8. Hi Fenway,

     

    Unfortunately this is not working. Its returns a empty result set.

    This is the code i have right now.

     

    The if construct in the foreach just takes care that the limit is 10, because i have 20 in total. I want the if within the foreach gone and just get 10 results total. I use the ksort because somehow ORDER BY ist really working with me :(

    		$comments = $wpdb->get_results("(
    		SELECT os_comments.comment_author AS author, os_posts.post_title AS title,os_posts.guid AS guid, os_comments.comment_date AS date
    		FROM os_comments, os_posts
    		WHERE os_comments.comment_post_ID = os_posts.ID
    		AND os_posts.post_status = 'publish'
    		AND os_comments.comment_approved = 1
    		ORDER BY os_comments.comment_date
    		DESC
    		LIMIT 10
    		)UNION ALL(
    		SELECT dna_comments.comment_author AS author, dna_posts.post_title AS title,dna_posts.guid AS guid, dna_comments.comment_date AS date
    		FROM dna_comments, dna_posts
    		WHERE dna_comments.comment_post_ID = dna_posts.ID
    		AND dna_posts.post_status = 'publish'
    		AND dna_comments.comment_approved = 1
    		ORDER BY dna_comments.comment_date
    		DESC
    		LIMIT 10
    		)
    		", ARRAY_A);
    
    		foreach ($comments as $c)
    		{
    			$arr[$c['date']] = $c;
    		}
    
    	#print_r($arr);
    	krsort($arr);
    	$Count = 0;
    		$CommentsList = '<ul>';
    		foreach ($arr as $comment):
    			if ($Count == $instance['amount'])
    				break;
    			$CommentsList .= '<li>'. $comment['author'] .' left a comment on <a href="'. htmlspecialchars($comment['guid']) .'">'. $comment['title'].'</a></li>';
    			$Count++;
    		endforeach;
    		$CommentsList .= '</ul>';
    
    	return $CommentsList;
    

     

    Please read this if you want. http://www.mail-archive.com/sqlite-users@sqlite.org/msg55669.html

     

  9. I am sorry to ask, but maybe you want to alter the it and show me how to do it ? Because i've tried several options and the order by outside the select query's results in a empty result set. Could you please show me ? Thanks.

  10. No, i want a total of 10. sorted on date. But i did read something about a bug with UNION+LIMIT. I've tested it, and it seems that the limit outside the parentheses only affects the first SELECT query.

     

    All i want is the LAST 10 (total) comments from both tables. I dont need 10 of each, just a total of 10, sorted on date.

     

  11. I've tried already this

                             "(
    		SELECT os_comments.comment_author AS author, os_posts.post_title AS title,os_posts.guid AS guid, os_comments.comment_date AS date
    		FROM os_comments, os_posts
    		WHERE os_comments.comment_post_ID = os_posts.ID
    		AND os_posts.post_status = 'publish'
    		AND os_comments.comment_approved = 1
    		ORDER BY os_comments.comment_date
    		DESC
    
    		)UNION(
    		SELECT dna_comments.comment_author AS author, dna_posts.post_title AS title,dna_posts.guid AS guid, dna_comments.comment_date AS date
    		FROM dna_comments, dna_posts
    		WHERE dna_comments.comment_post_ID = dna_posts.ID
    		AND dna_posts.post_status = 'publish'
    		AND dna_comments.comment_approved = 1
    		ORDER BY dna_comments.comment_date
    		DESC
    
    		)
                            LIMIT 10
    		"
    

     

    But somehow, now, it will only take the last 10 of os_ prefix. Another idea or am i doing something wrong ?

  12. Little MySQL help needed... Nobody is answering on the MySQL part on the forums

     

    I have this query

    (
    		SELECT os_comments.comment_author AS author, os_posts.post_title AS title,os_posts.guid AS guid, os_comments.comment_date AS date
    		FROM os_comments, os_posts
    		WHERE os_comments.comment_post_ID = os_posts.ID
    		AND os_posts.post_status = 'publish'
    		AND os_comments.comment_approved = 1
    		ORDER BY os_comments.comment_date
    		DESC
    		LIMIT 0,10
    		)UNION(
    		SELECT dna_comments.comment_author AS author, dna_posts.post_title AS title,dna_posts.guid AS guid, dna_comments.comment_date AS date
    		FROM dna_comments, dna_posts
    		WHERE dna_comments.comment_post_ID = dna_posts.ID
    		AND dna_posts.post_status = 'publish'
    		AND dna_comments.comment_approved = 1
    		ORDER BY dna_comments.comment_date
    		DESC
    		LIMIT 0,10
    		)
    

     

    But now i want 10 total instead of 10 of each.....

     

    Can someone help me out herE ?

  13. Can someone tell me what is NOT good with this query ?

    		$comments = $wpdb->get_results("
    		SELECT os_comments.comment_author AS author, os_posts.post_title AS title,os_posts.guid AS guid, os_comments.comment_date AS date
    		FROM os_comments, os_posts
    		WHERE os_comments.comment_post_ID = os_posts.ID
    		AND os_posts.post_status = 'publish'
    		AND os_comments.comment_approved = 1
    		ORDER BY os_comments.comment_date
    		DESC
    		UNION ALL
    		SELECT dna_comments.comment_author AS author, dna_posts.post_title AS title,dna_posts.guid AS guid, dna_comments.comment_date AS date
    		FROM dna_comments, dna_posts
    		WHERE dna_comments.comment_post_ID = dna_posts.ID
    		AND dna_posts.post_status = 'publish'
    		AND dna_comments.comment_approved = 1
    		ORDER BY dna_comments.comment_date
    		DESC
    		", ARRAY_A);

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