Jump to content

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)");
}
}
?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.