PDA

View Full Version : sql/php error



junior84
04-16-2007, 10:52 PM
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";

} ?>

thetestingsite
04-17-2007, 01:33 AM
The part in red in the code below is not defined.



$db = mysql_select_db($dbName, $link);


You need to change that to:


$db = mysql_select_db($db_name, $connection);


That's it, hope this helps.

boxxertrumps
04-17-2007, 01:04 PM
the $link variable isn't defined either. You were probably thinking $connection
Also, you just gave us your MySQL username and password...

thetestingsite
04-18-2007, 12:25 AM
Ah yes, looked right over that. Fixed now in my code above.