SitePoint Sponsor

User Tag List

Page 3 of 3 FirstFirst 123
Results 51 to 58 of 58
  1. #51
    SitePoint Addict
    Join Date
    Nov 2004
    Location
    Bristol
    Posts
    235
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks again r937

    I thought I'd already tried that and sure enough when I put single quotes around $tour and/or $golferentry I get:-

    parse error, unexpected T_VARIABLE in /pub/home/gbg141/htdocs/content/golfer-form.php on line 88

    $golferentry = $_POST['golferentry'];
    $tour = $_POST['tour'];
    $result = @mysql_query('SELECT G.Golfer, T.Tournament, T.T_Date, F.Position FROM tbl_tournaments AS T,
    tbl_golfers AS G LEFT OUTER JOIN tbl_finish_pos AS F ON T.ID = F.TournamentID AND F.GolferID = G.ID
    WHERE T.Tour = '$tour' AND G.Golfer = '$golferentry' ');

    I also tried putting double quotes around them and the page then displays ok but nothing is returned when you enter a golfer.

    Do you have any other ideas?

    Thanks again

  2. #52
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,250
    Mentioned
    59 Post(s)
    Tagged
    3 Thread(s)
    other ideas?

    yeah, start a new thread in the php forum and get those guys to show you how to create an sql string with single quotes in it

    i don't do php, sorry

    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #53
    SitePoint Wizard swdev's Avatar
    Join Date
    Oct 2004
    Location
    UK
    Posts
    1,053
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you need to escape single quotes within a single-quoted string like this

    PHP Code:
     $result = @mysql_query('SELECT G.Golfer, T.Tournament, T.T_Date, F.Position FROM tbl_tournaments AS T,
     tbl_golfers AS G LEFT OUTER JOIN tbl_finish_pos AS F ON T.ID = F.TournamentID AND F.GolferID = G.ID
     WHERE T.Tour = \'$tour\' AND G.Golfer = \'$golferentry\' '
    ); 

  4. #54
    SitePoint Addict
    Join Date
    Nov 2004
    Location
    Bristol
    Posts
    235
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok no worries, I'll ask in the php forum as it's moving off subject now.

    Thanks for all your assistance over the last few weeks r937. You've been an immense help way beyond the call of duty, cheers.

    daddyg

  5. #55
    SitePoint Addict
    Join Date
    Nov 2004
    Location
    Bristol
    Posts
    235
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    swdev

    Actually I recognised that as being the problem after r937's last comment. I escaped the quotes like so:-

    $dbcnx = @mysql_connect('host', 'username', 'password');
    if(!$dbcnx){
    die('<p>Unable to connect to the server at this time.</p>' );
    }

    //Select the golf database
    if(!@mysql_select_db('database')){
    die('<p>Unable to locate the golf database at this time.</p>');
    }

    if(isset($_POST['golferentry']))
    {


    $golferentry = $_POST['golferentry'];
    $tour = $_POST['tour'];
    $result = @mysql_query('SELECT G.Golfer, T.Tournament, T.T_Date, F.Position FROM tbl_tournaments AS T,
    tbl_golfers AS G LEFT OUTER JOIN tbl_finish_pos AS F ON T.ID = F.TournamentID AND F.GolferID = G.ID
    WHERE T.Tour = \'$tour\' AND G.Golfer = \'$golferentry\' ');

    if(!$result)
    {
    die('<p>Error performing query: ' . mysql_error() . '</p>');
    }

    //Display result on page in a paragraph
    while ($row = mysql_fetch_array($result) )
    {
    $Golfer = $row['Golfer'];
    $fp = $row['Position'];

    if(!isset($fp))
    {
    // $var is null (does not exist at this time) and the execution goes here
    $fp = "-";
    }

    $Tournament = $row['Tournament'];
    $TournamentDate = $row['T_Date'];

    echo('<p>$Golfer<br />$fp<br />$Tournament<br />$TournamentDate</p>');
    }

    }


    ?>


    Now the page displays but entering Tiger Woods in the form produces no output. So I tried escaping single quotes around the last line

    echo(' <p>\'$Golfer\'<br />\'$fp\'<br />\'$Tournament\'<br />\'$TournamentDate\'</p> ');

    but still no output

    http://www.golfbettingguide.com/content/golfer-form.php

  6. #56
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,250
    Mentioned
    59 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by daddyg
    that definitely is a php problem

    just look at the html that this page produces --

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML><HEAD>
    <META http-equiv=Content-Type content="text/html; charset=windows-1252"></HEAD>
    <BODY></BODY></HTML>
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  7. #57
    SitePoint Addict
    Join Date
    Nov 2004
    Location
    Bristol
    Posts
    235
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thats weird, all my pages are xhtml

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    Nevertheless, it's a php issue so I'll post this in the php forum

    Cheers.

  8. #58
    Not now, I'm kinda busy. pdxi's Avatar
    Join Date
    Dec 2004
    Location
    Oakland, California
    Posts
    784
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by daddyg
    Actually innodb tables aren't listed in the drop down menu in phpmyadmin.
    That may be because they're not supported by your MySQL server - ? Have you checked with your ISP to see if their installed version of MySQL supports InnoDB tables? Or, if you installed the server yourself, did you make sure to enable InnoDB support?
    Jeffrey Hunt, freelance PHP & MySQL developer
    Resume: http://www.jeffreyhunt.org/resume/


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
  •