I am trying to populate a dropdown, but cannot get the sql to return what I want. Can someone please help me with this error that I am getting in case 1? I am not using case 2 or the default case yet.
"<br />
<b>Warning</b>: mysql_fetch_arr ay(): supplied argument is not a valid MySQL result resource in <b>/home/user21/public_html/mp3/enterjob_2.php</b> on line <b>23</b><br />
<br />
<b>Notice</b>: Undefined variable: temp in <b>/home/user21/public_html/mp3/enterjob_2.php</b> on line <b>26</b><br />
"
Ultimately, I want to use the results to populate a dropdown, and am trying to get the data in a format that I can use in javascript, but keep getting the error. I am trying to make a name:value pair, so I can move over to the javascript side and manipulate the string and insert values into an existing dropdown. If there is a better way, please let me know. Thank you.
My php code is:
[php]
<?php
$host="localhos t"; // Host name
$username="mysq lusername"; // Mysql username
$password="mysq lpassword"; // Mysql password
$db_name="testd b"; // Database name
if($_GET['action'] == 'getOptions'){
// Connect to server and select databse.
mysql_connect(" $host", "$username" , "$password" )or die("cannot connect");
mysql_select_db ("$db_name") or die("cannot select DB");
switch($_GET['jobtype']){
case 0:
break;
case 1:
error_reporting (E_ALL);
ini_set('displa y_errors', True);
$sql="Select id, yardtype From YardTypes";
while ($row = mysql_fetch_arr ay($sql) )
$temp = $temp.$row[id].":".$row[yardtype].";";
echo ($temp);
break;
case 2: //Internet
break;
default: //User has selected all required information...s ave job
$jobtype=$_POST['jobtype'];
$jobdescription =$_POST['jobdescription '];
$sql="INSERT INTO $tbl_name (userid, jobtype, jobdescription) VALUES('$userid ', '$jobtype', '$jobdescriptio n')";
if (mysql_query($s ql))
header("locatio n:thankyou.php" );
else
echo "The server is temporarily unavailable. We apologize for the inconvenience." ;
break;
}
}
?>
[/php]
3 1392 pbmods 5,821
Recognized Expert Expert
Heya, Mike.
Before calling mysql_fetch_arr ay(), you must first execute your SQL query and generate a result resource by using mysql_query(): -
$sql="Select id, yardtype From YardTypes";
-
-
$res = mysql_query($sql);
-
-
if( empty($res) )
-
{
-
echo $sql, '<br /><br />', mysql_error();
-
}
-
-
while( $row = mysql_fetch_assoc($res) )
-
{
-
.
-
.
-
.
-
Heya, Mike.
Before calling mysql_fetch_arr ay(), you must first execute your SQL query and generate a result resource by using mysql_query(): -
$sql="Select id, yardtype From YardTypes";
-
-
$res = mysql_query($sql);
-
-
if( empty($res) )
-
{
-
echo $sql, '<br /><br />', mysql_error();
-
}
-
-
while( $row = mysql_fetch_assoc($res) )
-
{
-
.
-
.
-
.
-
That worked great...thank you very much for the second set of eyes. I guess I have been working too much today.
pbmods 5,821
Recognized Expert Expert
Heya, Mike.
Glad to hear you got it working! Good luck with your project, and if you ever need anything, well, you know... :)
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: sky2070 |
last post by:
Parse error: parse error, unexpected T_OBJECT_OPERATOR, expecting ')'
in c:\inetpub\wwwroot\session.php on line 19
can anyone tell me what is wrong with this code???
<?
// Define the Session class
class Session
{
// Define the properties:
|
by: Wayno |
last post by:
My php logs are coming up empty. I have done all I can think of, and
all that made sense to me. Can someone take a look at my php.ini
please and tell me what you think may be the problem.
I double-checked the path to my error log. It is in
/var/www/logs/php_error_log
Thanks. :)
-Wayne Stevenson
|
by: Dave |
last post by:
Hello all,
I found Herb Sutter's article regarding error handling in the most recent
CUJ to be very, very good. However, in trying to apply what I learned from
the article, I am left with some questions.
I have a function that takes a std::string (that represents a file name) as
a parameter. This function reads in the contents of the file and returns a
struct representing the file's content.
|
by: WindAndWaves |
last post by:
Hi Gurus
The page below has a strange error. It seems to be working very well, just
when you enter 8 or 9 for day, month or year then you get an error. I
really have no idea where that is coming from. Can you help?
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD>
|
by: Peter Frost |
last post by:
Please help
I don't know if this is possible but what I would really like to do is
to use On Error Goto to capture the code that is being executed when
an error occurs.
Any help would be much appreciated.
Thanks in advance
| |
by: jeff regoord |
last post by:
A user inputs a float value. The scanf() function gets the value.
However, I need to create an error handler with an if else statement
saying invalid input if the input is not a number. Does anybody know
how I could do this?
|
by: jer006 |
last post by:
Hi I am writing a select statement that has an arithmetic function
inside a case statement that uses logic to decide whether to divide or
multiply and when I run the arithmetic statements outside the case
statement they work fine, but blow up with an overflow error in the
case statement. The select looks like:
SELECT a.acct_cd,
a.crrncy_cd,
a.mkt_val,
c.rate,
|
by: 2DIL |
last post by:
hello all experts,
basically, i have a very small project, in which 97% of the work is complete. yet there is an issue which i cannot solve and i have no error to indicate what the problem is.Perhaps, in this case, it might just be a bad thing
I have 2 webpages, one with a datepicker in jscript with an id/name ="calendar";
this passes its value back into a textbox which is then submitted to the second webpage(database driven- mssql)......
|
by: FutureShock |
last post by:
I am using a registration class to process a registration form and need
some opinions on returning error messages.
I am self referring the page on submit.
I would like to send each form field to the class for processing
(validating, sanitizing, etc..) So far no problem.
Now I am throwing ideas around on how best to check for error messages
to the users.
|
by: chienee |
last post by:
here is the code
<?php
session_cache_limiter('private,must-revalidate');
session_start();
require_once("config.php");
include ("classes/db_functions.php");
include ("classes/display.php");
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |