Hi
Sorry for my terreble english.
On my local (win) comp i have apache+mysql+ph p 4.05
I'm counting rows using mysql_num_rows function, and everything works fine.
When i upload php file on server it says:
Warning: mysql_num_rows( ): supplied argument is not a valid MySQL result
resource in /home/optikara/public_html/crosun/izn/insert_form.php on line 80
Server runs php 5.0.5
Code is:
--------------------------
//connect to database code goes here
$result_v_smjes taj = mysql_query("se lect * from v_smjestaja order by
v_smjestaja_naz iv ASC", $db);
// some other html code goes here
if (mysql_num_rows ($result_v_smje staj)) {
print "<select name=\"v_smjest aja\">\n";
while ($qry = mysql_fetch_arr ay($result_v_sm jestaj)) {
print "<option
value=\"$qry[id_smjestaja]\">$qry[v_smjestaja_naz iv]</option>";
}
print "</select>\n";
}
--------------------------
On my local comp this works. Plz any solution, in plain simple code:)))
tnx in advance.
Dejan 7 1918
Dejan wrote: Hi
Sorry for my terreble english.
On my local (win) comp i have apache+mysql+ph p 4.05 I'm counting rows using mysql_num_rows function, and everything works fine. When i upload php file on server it says:
Warning: mysql_num_rows( ): supplied argument is not a valid MySQL result resource in /home/optikara/public_html/crosun/izn/insert_form.php on line 80 Server runs php 5.0.5
Code is: -------------------------- //connect to database code goes here
$result_v_smjes taj = mysql_query("se lect * from v_smjestaja order by v_smjestaja_naz iv ASC", $db); // some other html code goes here
if (mysql_num_rows ($result_v_smje staj)) { print "<select name=\"v_smjest aja\">\n"; while ($qry = mysql_fetch_arr ay($result_v_sm jestaj)) { print "<option value=\"$qry[id_smjestaja]\">$qry[v_smjestaja_naz iv]</option>"; } print "</select>\n"; } --------------------------
On my local comp this works. Plz any solution, in plain simple code:))) tnx in advance. Dejan
1. Always check the result from mysql_query (and all similar mysql_ calls).
2. When it fails, check the error message with mysql_error().
--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp. js*******@attgl obal.net
=============== ===
Some hints:
- You don't need to pass your database connection to mysql_query() (2nd
argument)
- When sending queries to your database *always* check for errors using
sth. like
mysql_query('.. .') or die(mysql_error ());
- Use shorter variable names to avoid typing errors
- Use single quotes ('...') for HTML if you don't like escaping all the
double quotes too much. ;)
milahu wrote: Some hints: - You don't need to pass your database connection to mysql_query() (2nd argument) - When sending queries to your database *always* check for errors using sth. like mysql_query('.. .') or die(mysql_error ()); - Use shorter variable names to avoid typing errors - Use single quotes ('...') for HTML if you don't like escaping all the double quotes too much. ;)
No, you don't *need* to pass the database connection. But it's a good idea to
do so. And it never hurts.
If you don't, PHP will use the last opened connection. That may be good now -
but changes in the code at a later date may change that. Now you've added a bug
which can be hard to fix (it fails in an area of code you didn't touch).
Also, I prefer *longer* more descriptive variable names. I don't understand
Dejan's native language, but these variables don't look exactly random to me.
I'm sure they mean something to him.
--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp. js*******@attgl obal.net
=============== ===
Write your code like this:
$query = "....";
$result = mysql_query($qu ery);
if($result) {
$num_rows = mysql_num_rows( $result); // notice the Result Resource
here //
} else {
echo mysql_error();
// die();
}
Best Regards,
ppl, tnx very much on your anwsers.
I have dealed with this problem and solved it.
I have added this error checking, buth the real error was tiping mistake.
I have named mysql table "gred", and neaded "grad". and then mysql sead
"mysql_num_rows (): supplied argument is not a valid MySQL result
resource "
tnx again
Dejan
<we*****@gmail. com> wrote in message
news:11******** *************@t 31g2000cwb.goog legroups.com... Write your code like this:
$query = "...."; $result = mysql_query($qu ery); if($result) { $num_rows = mysql_num_rows( $result); // notice the Result Resource here // } else { echo mysql_error(); // die(); }
Best Regards,
Dejan wrote: Hi
Sorry for my terreble english.
On my local (win) comp i have apache+mysql+ph p 4.05 I'm counting rows using mysql_num_rows function, and everything works fine. When i upload php file on server it says:
Warning: mysql_num_rows( ): supplied argument is not a valid MySQL result resource in /home/optikara/public_html/crosun/izn/insert_form.php on line 80 Server runs php 5.0.5
Code is:
[...] On my local comp this works. Plz any solution, in plain simple code:))) tnx in advance. Dejan
If it works at home then most likely the database connect code fails to
connect on the server.
Check the user and password parameters in your database connect code and
make sure they are correct on the server.
Bye!
First, you need to make your life a little easier by seperating out the
sql query:
$sql = "SELECT *
FROM my_table";
Assuming $db is a successful mysql_connect call...
$result = mysql_query($sq l, $db) or die ("<p>$sql</p>" .
mysql_error());
If the query is bad, the script wont try to go any further This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: David Nikel |
last post by:
I am attempting to create a login script.
The following snippet of code:
$query = "select * from auth where username='$username' and
password=password('$password')";
$result = mysql_query($query, $db_conn);
$num = mysql_num_rows($result);
echo $num;
|
by: Hebron Mak |
last post by:
Has anyone ran into problems where mysql_num_rows() return 0 when I
know the result set contains a certain number of rows? My code looks
something like this:
MYSQL_RES *result;
int numRows = -1;
mysql_query(conn, "show databases");
result = mysql_store_result (conn);
numRows = mysql_num_rows (result);
|
by: petemaxi |
last post by:
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\Program Files\xampp\htdocs\tockholes\includes\menu.inc.php on line 9
<div class="left">
<div class="menu">
<div class="boxhead" style="text-align:center;"> <strong>Menu</strong> </div>
<br />
<?php
require ('includes/db_conn.inc.php');
$query = "select * from menu order by item_order";
$result = mysql_query($query);
|
by: google |
last post by:
MySQL Server is version 4.1.7 (I know I should upgrade, and I will if
that is the problem but it has been working fine for 1.5 years now and
only recently has started to have this problem). Server is Linux
Redhat Enterprise 4. PHP is 4.4.4.
SQL STATEMENT:
==============
SELECT * FROM campaign_contact cc
LEFT JOIN optins_master co
ON cc.cc_cont_id=co.optin_id
|
by: d3vkit |
last post by:
Alright I can not figure this one out, so I'm guessing it's some simple typo and some extra eyes will help me spot it.
Here's the query (already connected to DB everything works in that respect):
$inactiveQuery = "SELECT userid,email_address,username,signup_date FROM users WHERE activated = 0";
$inactiveResult = mysql_query($inactiveQuery) or die('error: query failed: '.mysql_error());
$inactiveNumRows = mysql_num_rows($inactiveResult)...
| |
by: Ryanlawrence1 |
last post by:
Heya, I get these 2 errors:
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/themepar/public_html/changepass.php on line 20
You have not entered all the fields
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/themepar/public_html/changepass.php on line 34
Sorry You failed to enter the correct old password
I was wondering if anyone could help me, I have...
|
by: Sandman |
last post by:
Hi,
So I read the manual where it says to use mysql_affected_rows() for
everything except SELECT and SHOW, and use mysql_num_rows() for those
two, which actually return a result.
However, I wrote this little script below where I find that
mysql_num_rows() returns exactly the same output in the case of
SELECT, as mysql_affected_rows(). In the case of the INSERT,
mysql_num_rows() does not return anything.
|
by: seigaku |
last post by:
Hi everyone,
I've recently begun learning PHP and it looks like I took on too much so soon.
I'm attempting to fix a php script that detects whether or not a person is Eligible to join a tournament or not when they register and attempt to join. I'm doing it locally at the moment so i don't need to upload every 5 minutes. Any assistance would be appreciated.
On register.php, I am receiving the following error:
Warning:...
|
by: macdalor |
last post by:
Hi! I'm completely new to all dev and trying to put a website together using MySQLI and PHP; was running fine until I try to gather the DB content with the following script:
<?
$username="xxxxxx";
$password="xxxxxx";
$database="maxalien_davidloran";
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query="SELECT * FROM contacts";
|
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: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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
| |