Jump to content

Recommended Posts

 

 

 

 

 

 

 

 

 

 

 

 

 

$con = mysql_connect(DB_SERVER,DB_USER,DB_PASS);
mysql_select_db(DB_NAME, $con);
$results = mysql_query("SELECT tacticname, tactics FROM ".TBL_TACTICS." WHERE tacticname=".$_POST['tacticname']."");
$values = mysql_fetch_array($results);
$value = $values['tactics'];

 

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/jonoc33/public_html/clan/alpha/admin/tacticedit1.php on line 19

 

the bit that has the mysql_fetch_array is line 19.

 

This error just popped up, but I can't seem to figure out why it is occuring. The mysql query looks fine to me, and the variables are fine.

Link to comment
https://forums.phpfreaks.com/topic/83206-solved-annoying-php-error/
Share on other sites

I wonder why there is such a big white space in your post. Try:

 

<?php
mysql_connect(DB_SERVER,DB_USER,DB_PASS);
mysql_select_db(DB_NAME);
$results = mysql_query("SELECT tacticname, tactics FROM ".TBL_TACTICS." WHERE tacticname=".$_POST['tacticname']."");
$values = mysql_fetch_array($results);
$value = $values['tactics'];
?>

You need to check your queries for success prior to attempting using any results.

 

<?php

$con = mysql_connect(DB_SERVER,DB_USER,DB_PASS);
mysql_select_db(DB_NAME, $con);
if ($result = mysql_query("SELECT tacticname, tactics FROM ".TBL_TACTICS." WHERE tacticname = '{$_POST['tacticname']}')) {
 if (mysql_num_rows($result)) {
   $values = mysql_fetch_array($results);
   $value = $values['tactics'];
 } else {
   echo "no results found";
 }
} else {
 echo mysql_error();
}

?>

 

I also fixed the errors in your query.

EDITED:

Parse error: syntax error, unexpected '{' in /home/jonoc33/public_html/clan/alpha/admin/tacticedit1.php on line 17

 

Line 20: $value = $values['tactics'];

 

Current code:

$con = mysql_connect(DB_SERVER,DB_USER,DB_PASS);
mysql_select_db(DB_NAME, $con);
if ($result = mysql_query("SELECT tacticname, tactics FROM ".TBL_TACTICS." WHERE tacticname = '{$_POST['tacticname']}')") {
  if (mysql_num_rows($result)) {
    $values = mysql_fetch_array($results);
    $value = $values['tactics'];
  } else {
    echo "no results found";
  }
} else {
  echo mysql_error();
}

Find this line:

 

if ($result = mysql_query("SELECT tacticname, tactics FROM ".TBL_TACTICS." WHERE tacticname = '{$_POST['tacticname']}')") {

 

Change it to:

 

if ($result = mysql_query("SELECT tacticname, tactics FROM ".TBL_TACTICS." WHERE tacticname = '{$_POST['tacticname']}'")) {

Changed to new code now with that code change. The page now displays, but I still get the

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/jonoc33/public_html/clan/alpha/admin/tacticedit1.php on line 19

 

error

Ok i reverted back to my old code and put in mysql_error().

 

Unknown column 'fgfdgs' in 'where clause'

 

I've found that fgfdgs is the value of the 'tacticname' field.

What does where clause mean?

 

When you say "SELECT table_columns FROM table_name WHERE table_column=$value" that's the WHERE clause. Apparently, you're calling the table column fgfdgs and it doesn't exist.

that gibberish table does not exist, tacticname does exist and so does tactics, and they are spelt right.

Okay, :) Is that table suppose to exist or is it just an example?

 

I'm terribly sorry here, but I'm a bit confused. Can you please post the error you have now again?

Ok, basically there are 3 fields. Tacticname, tactics and map. the Tacticname field contains the gibberish thing that I said earlier, tactics contains what comes out of the mysql and map is out of the picture.

 

When I open up the page, it shows everything but it will not echo $value because it shows this error:

 

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/jonoc33/public_html/clan/alpha/admin/tacticedit1.php on line 19

 

Line 19 is this: $values = mysql_fetch_array($results);

 

My current code:

$con = mysql_connect(DB_SERVER,DB_USER,DB_PASS);
mysql_select_db(DB_NAME, $con);
if ($results = mysql_query("SELECT id, tacticname, tactics FROM ".TBL_TACTICS." WHERE id = '{$_POST['id']}'")) {
  if (mysql_num_rows($results)) {
    $values = mysql_fetch_array($results);
    $value = stripslashes($values['tactics']);
  } else {
    echo "no results found";
  }
} else {
  echo mysql_error();
}

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.