1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.
  2. Better Analytics for WordPress Get It Free

unable to delete data from mysql database

Discussion in 'MySQL' started by darkc999, Jan 6, 2012.

  1. #1
    hello
    i have desinged url loader for my site , its working fine but have little problem that it cant delete url at end after loading

    <?php
    // set time 1000
    set_time_limit(1000);
    // connect to db
    include ("../../config.php");
    // select data from database target domain and T2 table
    $result = mysql_query( "SELECT * FROM domain" )
    or die("SELECT Error: ".mysql_error());
    $resultx = mysql_query( "SELECT * FROM worth" )
    or die("SELECT Error: ".mysql_error());
    $num_rows = mysql_query($result);
    $num_rowsx = mysql_query($resultx);
    // fetching data
    while ($get_infox = mysql_fetch_assoc($resultx) && $get_info = mysql_fetch_assoc($result))
    {
    $domax="www.".$get_infox[domain];
    $doma=$get_info[domain];
    if ($doma != $domax[domain])
    {
    // load urls
    $url="http://www.w3db.org/".$doma."";
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_TIMEOUT, 15);
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1");
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $index=curl_exec($ch);
    $error=curl_error($ch);
    curl_close($ch);
    // deleting current loaded url
    echo "url loaded and deleted ".$url."<br />";
    mysql_query("DELETE FROM domain WHERE domain=".$doma.""); // problem here
    }
    else
    {
    echo "url skiped and deleted ".$url."<br />";
    mysql_query("DELETE FROM domain WHERE domain=".$doma.""); // problem here
    }
    }
    mysql_close($con);

    ?>

    i do not know why it cant delete code is ok no error i do not know why please help :(

    for test
    Table 1 :: domain having column domain
    Table 2 :: T1 having column domain

    task ::
    take url from (table 1) domain compare with (Table 2) domain url if not match loaded with curl and then delete else skip loading url and delete it.

    it load url but it end cant delete ??? help
     
    darkc999, Jan 6, 2012 IP
  2. ScottAN

    ScottAN Peon

    Messages:
    46
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Try just using some of those queries directly in MySQL. If you have phpMyAdmin installed (which you do if you are on a CPanel server) then just go in and run those queries manually. It will tell you in at least some detail what errors it finds or why it won't work.
     
    ScottAN, Jan 6, 2012 IP
  3. dgmdan

    dgmdan Peon

    Messages:
    12
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    When it ends up running the query, it's missing some quotes:
     DELETE FROM domain WHERE domain=foo
    Code (markup):
    What you want it to be is:
     DELETE FROM domain WHERE domain="foo";
    Code (markup):
    So change your code to:
     mysql_query("DELETE FROM domain WHERE domain=\"".$doma."\"");
    Code (markup):
    Also, I hope $doma has been sanitized if it contains user input. Otherwise you're writing code vulnerable to SQL injection.
     
    dgmdan, Jan 8, 2012 IP
  4. hbgalaxy

    hbgalaxy Member

    Messages:
    30
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    26
    #4
    Cant do you do through PHPmyadmin these days
     
    hbgalaxy, Jan 9, 2012 IP
  5. darkc999

    darkc999 Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    ya thanks :) i already fixed it as dgmdan said that quotes are missed so few days ago i fixed i forget quotes around $doma :D just an idiot
     
    darkc999, Jan 9, 2012 IP
  6. Irfi0009

    Irfi0009 Banned

    Messages:
    17,605
    Likes Received:
    33
    Best Answers:
    1
    Trophy Points:
    48
    #6
    yes this is a best code for dell ............
     
    Irfi0009, Jan 19, 2012 IP
  7. iama_gamer

    iama_gamer Active Member

    Messages:
    403
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    60
    #7
    It is preferrable to use single quotes : ' rather than double since double quotes may at times depend on certain MySql settings
     
    iama_gamer, Jan 26, 2012 IP
  8. darkc999

    darkc999 Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    ya i fixed it already i just quotes around $doma .....
     
    darkc999, Jan 26, 2012 IP