MySQL

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ken

    #1

    MySQL

    Parse error: parse error, unexpected T_STRING in
    C:\Apache2\Webp age\test_mysql. php on line 44

    I receive the above error when trying to insert data into a database. The
    statement used for insertion is:

    LINE 44: INSERT INTO ad_data ('website') Values('w');

    The database and table is working..

    I can connect to the database and the table.
    Table name is ad_data.
    Column1 name is id which is the primary key, integer, and auto incrementing
    Column2 name is website. Data in the website column is 'hhhh'

    All columns are NULL except for id.

    I can fetch data from the table. See below:

    $db_query = mysql_query("SE LECT website FROM ad_data") or die("Select
    Failed!");
    $db_results = mysql_fetch_arr ay($db_query);
    echo "Table data = ".$db_resul ts[0]."<br><br>";

    I have manually inserted data in the table.

    Everything seems to be working.

    Any suggestions for correcting the error in line 44?

    Thanks for the help.

    Ken


  • Aggro

    #2
    Re: MySQL

    Ken wrote:
    [color=blue]
    > LINE 44: INSERT INTO ad_data ('website') Values('w');[/color]

    Is this supposed to be php or sql?

    If sql, then:
    INSERT INTO ad_data (website) Values('w');

    Comment

    • Aggro

      #3
      Re: MySQL

      Ken wrote:
      [color=blue]
      > It is sql inside of
      > <?php
      > INSERT INTO ad_data (website) Values('w');
      > ?>
      > Do I need to add any leading script if it is sql inside of php?[/color]

      I am not the best person to answer php questions and this is not a group
      for php, but personally when I used php, I used database like this:

      <?php
      $link = mysql_connect(" localhost", "username", "password")
      or die("Could not connect");
      mysql_select_db ("databasename" )
      or die("Could not select database");

      $query = "SELECT * from tablename";
      $result = mysql_query($qu ery)
      or die("Query failed");
      ?>

      Comment

      • Aggro

        #4
        Re: MySQL

        Ken wrote:
        [color=blue]
        > It is sql inside of
        > <?php
        > INSERT INTO ad_data (website) Values('w');
        > ?>
        > Do I need to add any leading script if it is sql inside of php?[/color]

        I am not the best person to answer php questions and this is not a group
        for php, but personally when I used php, I used database like this:

        <?php
        $link = mysql_connect(" localhost", "username", "password")
        or die("Could not connect");
        mysql_select_db ("databasename" )
        or die("Could not select database");

        $query = "SELECT * from tablename";
        $result = mysql_query($qu ery)
        or die("Query failed");
        ?>

        Comment

        • Ken

          #5
          Re: MySQL

          It is sql inside of
          <?php
          INSERT INTO ad_data (website) Values('w');
          ?>
          Do I need to add any leading script if it is sql inside of php?

          Ken


          "Aggro" <spammerdream@y ahoo.com> wrote in message
          news:Q8sbc.16$F j.3@read3.inet. fi...[color=blue]
          > Ken wrote:
          >[color=green]
          > > LINE 44: INSERT INTO ad_data ('website') Values('w');[/color]
          >
          > Is this supposed to be php or sql?
          >
          > If sql, then:
          > INSERT INTO ad_data (website) Values('w');[/color]


          Comment

          • Aggro

            #6
            Re: MySQL

            Ken wrote:
            [color=blue]
            > It is sql inside of
            > <?php
            > INSERT INTO ad_data (website) Values('w');
            > ?>
            > Do I need to add any leading script if it is sql inside of php?[/color]

            I am not the best person to answer php questions and this is not a group
            for php, but personally when I used php, I used database like this:

            <?php
            $link = mysql_connect(" localhost", "username", "password")
            or die("Could not connect");
            mysql_select_db ("databasename" )
            or die("Could not select database");

            $query = "SELECT * from tablename";
            $result = mysql_query($qu ery)
            or die("Query failed");
            ?>

            Comment

            Working...