Results 1 to 4 of 4

Thread: sql/php error

  1. #1
    Join Date
    Apr 2007
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default sql/php error

    hello

    [QUOTE]<?php

    $db_name = "wilkiesh_newone";
    $connection = mysql_connect("localhost", "wilkiesh_johnboy", "johnboy") or die ("**** off");
    $table_name = "name";

    $db = mysql_select_db($dbName, $link); < -apparently this isnt valid SQL does anyone know of a replacement line please?
    $query = "select * from " . $table_name;
    $ressult = mysql_query($query, $connection) or die("**** off");
    $num = mysql_num_rows($result);


    if ($num != 0) {

    $file= fopen("results.xml", "w");

    $_xml ="<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\r\n";

    $_xml .="<site>\r\n";

    while ($row = mysql_fetch_array($result)) {

    if ($row["pageTitle"]) {

    $_xml .="\t<page title=\"" . $row["pageTitle"] . "\">\r\n";

    $_xml .="\t\t<file>" . $row["pageLink"] . "</file>\r\n";
    $_xml .="\t</page>\r\n";
    } else {

    $_xml .="\t<page title=\"Nothing Returned\">\r\n";
    $_xml .="\t\t<file>none</file>\r\n";

    $_xml .="\t</page>\r\n";
    } }

    $_xml .="</site>";

    fwrite($file, $_xml);

    fclose($file);

    echo "XML has been written. <a href=\"results.xml\">View the XML.</a>";

    } else {

    echo "No Records found";

    } ?>

  2. #2
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    The part in red in the code below is not defined.

    Code:
    $db = mysql_select_db($dbName, $link);
    You need to change that to:
    Code:
    $db = mysql_select_db($db_name, $connection);
    That's it, hope this helps.
    Last edited by thetestingsite; 04-18-2007 at 12:25 AM.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  3. #3
    Join Date
    Jun 2006
    Location
    Acton Ontario Canada.
    Posts
    677
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default

    the $link variable isn't defined either. You were probably thinking $connection
    Also, you just gave us your MySQL username and password...
    - Ryan "Boxxertrumps" Trumpa
    Come back once it validates: HTML, CSS, JS.

  4. #4
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    Ah yes, looked right over that. Fixed now in my code above.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

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
  •