---
title: "MySQL Error...!"
type: "forum-thread"
url: "https://www.webforum.nu/amne/php/117986-mysql-error"
topic: "PHP"
topic_url: "https://www.webforum.nu/amne/php"
author: "Guldstrand"
published: "2004-12-13T23:05:56.000Z"
updated: "2004-12-14T13:16:15.000Z"
replies: 4
views: 323
page: 1
pages: 1
language: "sv-SE"
site: "webForum — webforum.nu"
rights: "Upphovsrätten till varje inlägg tillhör dess författare."
attribution: "Citera som: webForum, https://www.webforum.nu/amne/php/117986-mysql-error"
---

# MySQL Error...!

## #1 — Guldstrand, 2004-12-13T23:05Z

Jag har laddat ner ett färdigt php-script, men jag får det inte till att fungera riktigt.  :( 

```
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/PROTECTED/public_html/PROTECTED/index.php on line 109
```

Felet ska tydligen ligga i 

```
while ($rows = mysql_fetch_array($query)){
```

Från index.php

```
<? 
$query = mysql_query("SELECT id,catname FROM db_cam_cat ORDER BY catname"); 
while ($rows = mysql_fetch_array($query)){ 
echo "<OPTION VALUE=\"$rows[id]\""; 
if ($sort == $rows[id]){ 
echo " SELECTED"; 
} 
$totalc = "SELECT id from db_cam WHERE cat = '$rows[id]' AND active = '1'"; 
$totalsc = mysql_query($totalc); 
$total_rowsc = mysql_num_rows($totalsc); 
echo ">$rows[catname] ($total_rowsc)\n"; 
} 
?>
```

 

Tabellen ser ut såhär:

```
CREATE TABLE db_cam_cat (
  id int(11) NOT NULL auto_increment,
  description varchar(255) default NULL,
  PRIMARY KEY  (id)
);

INSERT INTO db_cam_cat VALUES (1, 'Girls with Webcams', 'Webcams from different girls around the world...');
INSERT INTO db_cam_cat VALUES (2, 'Boys with Webcams', 'Webcams from different boys around the world...');
INSERT INTO db_cam_cat VALUES (3, 'Other Live Webcams', 'Webcams from different places around the world...');
INSERT INTO db_cam_cat VALUES (4, 'Online City Cams', 'Webcams from different citys around the world...');
INSERT INTO db_cam_cat VALUES (5, 'Animals & Zoo', 'Live cams around the world of animals and from Zoo\'s around...');
INSERT INTO db_cam_cat VALUES (6, 'Live beach cams', 'Online cams at seashores and beaches around the world...');
INSERT INTO db_cam_cat VALUES (7, 'Live Sex Cams', 'Live sex and nude cams around the world...');
INSERT INTO db_cam_cat VALUES (8, 'Live Boat Cams', 'Cams that are mounted on boat\'s around the world...');
INSERT INTO db_cam_cat VALUES (9, 'Live Wired Cams', 'Strange and Wired Cams around the world...');
INSERT INTO db_cam_cat VALUES (10, 'Live Airport Cams', 'Live cams from airports around the world...');
```

Hoppas att någon kan hjälpa mig att hitta felet!?  :q

Permalänk: https://www.webforum.nu/p/117986

## #2 — lunne82, 2004-12-13T23:09Z

Du har fel på frågan du skickar till databasen.

Ändra raden:
$query = mysql_query("SELECT id,catname FROM db_cam_cat ORDER BY catname");
till
$query = mysql_query("SELECT id,catname FROM db_cam_cat ORDER BY catname")or die(mysql_error());

Permalänk: https://www.webforum.nu/p/1506769

## #3 — Guldstrand, 2004-12-13T23:24Z

Det hjälpte inte...

Jag glömde tillägga att jag inte kan köra/skapa tabellen **db_cam_cat** i phpmyadmin heller.  :r

Får även ett fel i phpmyadmin när jag ska "köra" tabellen.

```
SQL-fråga: 

INSERT INTO db_cam_cat
VALUES ( 1, 'Girls with Webcams', 'Webcams from different girls around the world...' ) 
MySQL sa:  

#1136 - Column count doesn't match value count at row 1
```

Permalänk: https://www.webforum.nu/p/1506776

## #4 — lunne82, 2004-12-14T06:53Z

Du har inte skapat någon kolumn i tabellen för, i ditt exempel ovan, 'Girls with Webcams'. Du använder nu:

```
CREATE TABLE db_cam_cat (
  id int(11) NOT NULL auto_increment,
  description varchar(255) default NULL,
  PRIMARY KEY  (id)
);
```

men du skulle behöva:

```
CREATE TABLE db_cam_cat (
  id int(11) NOT NULL auto_increment,
  name varchar(100) default NULL,
  description varchar(255) default NULL,
  PRIMARY KEY  (id)
);
```

Permalänk: https://www.webforum.nu/p/1506803

## #5 — K++, 2004-12-14T13:16Z

Byt ut mysql_fetch_array mot mysql_fetch_assoc så borde det fungera..

Permalänk: https://www.webforum.nu/p/1506957

---

Tråden på webben: https://www.webforum.nu/amne/php/117986-mysql-error
