mySQL help please

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    mySQL help please

    <?php

    $connect = mysql_connect('localhost', 'root', '');

    if (!$connect){
    die('Could not connect: ' . mysql_error());
    }

    echo 'Connected successfuly' . '<br/><br/>';

    mysql_select_db("site");

    $insert = "INSERT INTO site (name) VALUES ('waptrick.com');";
    mysql_query("$insert");

    $query = "SELECT name FROM games";
    $result = mysql_query($query);
    $my_rows;

    while($row = mysql_fetch_array($result, MYSQL_ASSOC))
    {
    $my_rows = $my_rows . "Site Name : {$row['name']} <br />";
    }

    mysql_close($connect);

    echo "$my_rows;"


    ?>

    ////////////////////////////////////////////////
    im having 2 problems with this code...the first is its not inserting the new row into the database
    the second is "Notice: Undefined variable: my_rows in C:\wamp\www\mysql\connect.php on line 22"

    i cant work out the problem for either one of these errors could someone please help me

    Added after 51 minutes:

    got it to insert the row im just having this problem "Notice: Undefined variable: my_rows in C:\wamp\www\mysql\connect.php on line 22" still anything ive missed ?
    Last edited by Guest; 02.10.10, 09:30.

    #2
    what is in connect.php @line 22 ?

    also use [php] tag when u post code.
    sigpic

    Comment


      #3
      $my_rows = $my_rows . "Site Name : {$row['name']} <br />";

      i cancel out the error by using
      $my_rows = @$my_rows . "Site Name : {$row['name']} <br />";
      to not display the error so im guessing thats the cause but why and how would i fix it ?

      Comment


        #4
        what's thet?
        $query = "SELECT name FROM games";
        $result = mysql_query($query);
        $my_rows;

        remove the red line or make it

        $query = "SELECT name FROM games";
        $result = mysql_query($query);
        $my_rows=NULL;

        Free Mobile Web Scripts by me: Free Youtube Downloader, Tweets Reader, Facebook Wall Posts Reader
        PHP Tutorials: How to Secure Your PHP Script (PHP SECURITY)
        Want to Develop/Edit your WAP/Web Site? Add me to Gtalk (gmail) 'lakshan1989' or PM me.

        Comment


          #5
          thanks
          $my_rows=NULL;
          worked perfectly

          Comment

          Working...
          X