You'd probably need to use:
@mysql_close();
$db = @mysql_connect($host,$usr,
or die("<p>Kan ej ansluta till databasservern.</p>");
@mysql_select_db($db)
or die("<p>Kan ej ansluta till databasen " . $db . ".</p>");
-r-
Main Topics
Browse All TopicsHaving this code:
if($_POST['medlemsnr_1'] == "alla" && empty($_POST['medlemsnr_2'
{ $SQL = " SELECT * FROM medlem "; }
// Om bara "Har hamnplats" är markerat
if(!empty($_POST['medlemsn
{ $SQL = " SELECT * FROM medlem WHERE brygga IS NOT NULL"; }
// Om bara "Har varvsplats" är markerat
if(!empty($_POST['medlemsn
{ $SQL = " SELECT * FROM medlem WHERE omrade IS NOT NULL"; }
//Om bara "Lägsta nummer" valts med comboboxen
if(!empty($_POST['medlemsn
{ $SQL = " SELECT * FROM medlem WHERE medlemsnr >= '$_POST[medlemsnr_4]'"; }
//Om bara "Högsta nummer" valts med comboboxen
if(!empty($_POST['medlemsn
{ $SQL = " SELECT * FROM medlem WHERE medlemsnr <= '$_POST[medlemsnr_5]'"; }
//Om bara "Lägsta nummer" valts i formulärrutan (inte comboboxen)
if($_POST['medlemsnr_6'] !== "Lägsta nr" && $_POST['medlemsnr_6'] > 0 && empty($_POST['medlemsnr_1'
{ $SQL = " SELECT * FROM medlem WHERE medlemsnr >= '$_POST[medlemsnr_6]'"; }
//Om bara "Högsta nummer" valts i formulärrutan (inte comboboxen)
if($_POST['medlemsnr_7'] !== "Högsta nr" && $_POST['medlemsnr_7'] > 0 && empty($_POST['medlemsnr_1'
{ $SQL = " SELECT * FROM medlem WHERE medlemsnr <= '$_POST[medlemsnr_7]'"; }
// Om både "Lägsta nummer" och "Högsta nummer" valts i comboboxen
if(!empty($_POST['medlemsn
{ $SQL = " SELECT * FROM medlem WHERE medlemsnr >= '$_POST[medlemsnr_4]' AND medlemsnr <= '$_POST[medlemsnr_5]' "; }
// Om både "Lägsta nummer" och "Högsta nummer" valts i formulärrutorna (inte comboboxarna)
if($_POST['medlemsnr_6'] !== "Lägsta nr" && $_POST['medlemsnr_6'] > 0 && $_POST['medlemsnr_7'] !== "Högsta nr" && $_POST['medlemsnr_7'] >0 && empty($_POST['medlemsnr_1'
{ $SQL = " SELECT * FROM medlem WHERE medlemsnr >= '$_POST[medlemsnr_6]' AND medlemsnr <= '$_POST[medlemsnr_7]' "; }
// Om "Eller endast" valts i formulärrutan (inte comboboxarna)
if($_POST['medlemsnr_8'] !== "" && $_POST['medlemsnr_8'] > 0 && $_POST['medlemsnr_7'] == "Högsta nr" && $_POST['medlemsnr_6'] == "Lägsta nr" && empty($_POST['medlemsnr_1'
{ $SQL = " SELECT * FROM medlem WHERE medlemsnr = '$_POST[medlemsnr_8]' "; }
//echo"<br>SQL: $SQL";
$ret = mysql_db_query($db, $SQL, $cid);
if (!$ret) { echo( mysql_error()); }
else {
while ($row = mysql_fetch_array($ret)) { // This is line 89
$id = $row["id"];
$brygg_bredd = $row["brygg_bredd"];
$bat_bredd = $row["bat_bredd"];
$bat_langd = $row["bat_langd"];
$medlemsnr = $row["medlemsnr"];
$fornamn = $row["fornamn"];
$efternamn = $row["efternamn"];
$adress = $row["adress"];
$postnr = $row["postnr"];
$ort = $row["ort"];
$betalt = $row["betalt"];
$typ = $row["typ"];
$brygga = $row["brygga"];
$bat_vikt = $row["bat_vikt"];
--------------------------
and after having "massaged" the data I get from the database, I'd like to run this code:
--------------------------
@mysql_close();
@mysql_connect($host,$usr,
or die("<p>Kan ej ansluta till databasservern.</p>");
@mysql_select_db($db)
or die("<p>Kan ej ansluta till databasen " . $db . ".</p>");
$SQL = " UPDATE medlem SET faktura_nr = '$fakturanr', faktura_summa = '$totalt', faktura_datum = curdate() WHERE medlemsnr = '$medlemsnr' ";
$ret = mysql_db_query($db, $SQL, $cid);
if (!$ret) { echo( mysql_error()); }
I get this message from MySQL when running the script:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in D:\Mina dokument\htdocs\tbk\kansli
Can anyone of you gurus, please, help me and explain what is wrong and how I could correct it.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Thanks Zyloch and Roonaan!
If I follow Zyloch's suggestion, I get: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in D:\Mina dokument\htdocs\tbk\kansli
If I follow Roonaan's suggestion, I get: Cannot connect to database Resource id #5.
What should I do?
Business Accounts
Answer for Membership
by: ZylochPosted on 2007-03-24 at 18:45:17ID: 18786962
I don't think you need to close your database connection. Remove:
$pwd)
@mysql_close();
@mysql_connect($host,$usr,
or die("<p>Kan ej ansluta till databasservern.</p>");
@mysql_select_db($db)
or die("<p>Kan ej ansluta till databasen " . $db . ".</p>");
and you should be fine, since you are already connected to the database.