Jump to content

Help with mysql_fetch_array()


anon

Recommended Posts

Warning:  mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/***/public_html/***/spider.php on line 13

 

Here is my current code -

<?php
$dbhost = '***';
$dbuser = '****';
$dbpass = '*****';

$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error with database');

$dbname = '****';
mysql_select_db($dbname);

$getlist=mysql_query("SELECT u_id FROM addurl");

while($row=mysql_fetch_array($getlist)){
   $text = file_get_contents($row[0]);
   mysql_query("insert into *** (content) values ($text)");
}
?>

 

The code should fetch and index a page that has been specified in a database.

Link to comment
https://forums.phpfreaks.com/topic/83456-help-with-mysql_fetch_array/
Share on other sites

Nope, no luck

 

Here's my code at the mo

<?php
$dbhost = 'localhost';
$dbuser = '***';
$dbpass = '****';

$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error with database');

$dbname = 'Direx';
mysql_select_db($dbname);

$getlist=mysql_query("SELECT u_link FROM addurl") or die("Query error ".mysql_error());

while($row=mysql_fetch_array($getlist)){
   $text = file_get_contents($row[0]);
   mysql_query("insert into Index (content) values ($text)");
}
?>

If that doesn't get you going, the only thing I would try is:

 

<?php
$dbhost = 'localhost';
$dbuser = '***';
$dbpass = '****';

$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error with database');

$dbname = 'Direx';
mysql_select_db($dbname, $conn);
// rest of your script

 

PhREEEk

you need this :

<?php

$getlist=mysql_query("SELECT u_id FROM addurl");
// add this if statement   
if(mysql_num_rows($getlist)){
while($row=mysql_fetch_array($getlist)){
   $text = file_get_contents($row[0]);
   mysql_query("insert into *** (content) values ($text)");
}
}
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.