SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    Ranking in the $$$ tbase's Avatar
    Join Date
    Jun 2004
    Location
    OVER THERE ->
    Posts
    542
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Exclamation Php variable in MySQL problems

    Please tell me why this wont work

    Code:
    $kwmy = $k['term'];
        $svolume = number_format($k['no']*($se['yahoo']+$se['google']+$se['msn'])/$se['yahoo']);
        $gvol = number_format($k['no']*$se['google']/$se['yahoo']);
        $yvol = number_format($k['no']);
        $msnvol = number_format($k['no']*$se['msn']/$se['yahoo']);
        $gcomp = $results1['googlel'][0];
        $gtotal = $results1['google0'][0];
        $keiround = (ceil($kei));
            
        $query = "INSERT INTO data
                     (kw, svolume, gvol, yvol, msnvol, kei, gcomp, gtotal)
    VALUES('"$kwmy"', "$svolume", "$gvol", "$yvol", "$msnvol", "$keiround", "$gcomp", "$gtotal")";
    $dbw = mysql_query($query);
    I want to BUY Google API Keys (Soap).
    PM me if you got one to sell.

  2. #2
    SitePoint Enthusiast
    Join Date
    Jan 2007
    Location
    Ballarat, Vic. Australia
    Posts
    61
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by tbase View Post
    Please tell me why this wont work

    Code:
    $kwmy = $k['term'];
        $svolume = number_format($k['no']*($se['yahoo']+$se['google']+$se['msn'])/$se['yahoo']);
        $gvol = number_format($k['no']*$se['google']/$se['yahoo']);
        $yvol = number_format($k['no']);
        $msnvol = number_format($k['no']*$se['msn']/$se['yahoo']);
        $gcomp = $results1['googlel'][0];
        $gtotal = $results1['google0'][0];
        $keiround = (ceil($kei));
            
        $query = "INSERT INTO data
                     (kw, svolume, gvol, yvol, msnvol, kei, gcomp, gtotal)
    VALUES('"$kwmy"', "$svolume", "$gvol", "$yvol", "$msnvol", "$keiround", "$gcomp", "$gtotal")";
    $dbw = mysql_query($query);
    I'd say that you have way too many double quotes in there. I would have done it like this:

    $query = "INSERT INTO data
    (kw, svolume, gvol, yvol, msnvol, kei, gcomp, gtotal)
    VALUES('".$kwmy."','".$svolume."', '".$gvol."', '".$yvol."', '".$msnvol."', '".$keiround."', '".$gcomp."', '".$gtotal"')";

    That's kind of an 'old school' way of doing it and I'm sure others will come up with a few other ways ... but at the moment, your query ends at the second double quote, so to PHP it looks like this:

    $query = "INSERT INTO data
    (kw, svolume, gvol, yvol, msnvol, kei, gcomp, gtotal)
    VALUES('"


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •