473,396 Members | 2,014 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Help needed with script

I am quite new to all this and have stumbled at the first gate.

Can anyone tell me what is wrong with this?

<?php

$connection =
mysql_connect("domain","databaseusername","databas epassword");

$sql = 'SELECT * ';
$sql .= 'FROM `PageElements` ';
$sql .= 'WHERE pageid = 1 LIMIT 0, 30';

$result=mysql_query($sql,$connection);

while ($row = mysql_fetch_row($result)) * error message refers to this
line
{
for ($i=0; $i<mysql_num_fields($result); $i++)
echo $row[$i] . " ";

echo "\n";

}
mysql_close($connection);
?>

I am getting the following error message:

Warning: Supplied argument is not a valid MySQL result resource in
/home/nprie/public_html/index2.php on line 26 (i have put an asterisk
next to line 26 above) as above script is a fragment of a php file.

Cheers.

Jul 17 '05 #1
3 1186
Have you tried including a

mysql_select_db(...);

after the call to mysql_connect(...); Its the mistake that I always make.

Derek

st***********@boston-spa.org.uk wrote:
I am quite new to all this and have stumbled at the first gate.

Can anyone tell me what is wrong with this?

<?php

$connection =
mysql_connect("domain","databaseusername","databas epassword");

$sql = 'SELECT * ';
$sql .= 'FROM `PageElements` ';
$sql .= 'WHERE pageid = 1 LIMIT 0, 30';

$result=mysql_query($sql,$connection);

while ($row = mysql_fetch_row($result)) * error message refers to this
line
{
for ($i=0; $i<mysql_num_fields($result); $i++)
echo $row[$i] . " ";

echo "\n";

}
mysql_close($connection);
?>

I am getting the following error message:

Warning: Supplied argument is not a valid MySQL result resource in
/home/nprie/public_html/index2.php on line 26 (i have put an asterisk
next to line 26 above) as above script is a fragment of a php file.

Cheers.

Jul 17 '05 #2
mysql_select_db('DB_NAME', $connection) between connecting to mysql and
your 1st query

micha

Jul 17 '05 #3
Many thanks - that solved the problem.

Cheers

Jul 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Robert V | last post by:
Hi all, I could use some help programming on of my Perl script to handle different submit buttons within the same form. Here is what I have so far. A user goes to a Web form and inputs some data...
14
by: StumpY | last post by:
HI, I have set up a page with a form which appends data to a .csv file on my asp server, this is to enable a limited number of users to add news threads to this file, which contains the data in...
8
by: Johnny Knoxville | last post by:
I've added a favicon to my site (http://lazyape.filetap.com/) which works fine if you add the site to favourites the normal way, but I have some JavaScript code on a couple of pages with a link,...
28
by: stu_gots | last post by:
I have been losing sleep over this puzzle, and I'm convinced my train of thought is heading in the wrong direction. It is difficult to explain my circumstances, so I will present an identical...
7
by: mike | last post by:
Hello, I am kind of new to this javascript stuff and I am constantly having problems trying to get my webpage validated. I have the following <script>printdate();</script> and when I validate it...
3
by: % =joe % | last post by:
I cannot get this code to work. Very simple...I have three list menus. I want to do a check before the form submits to make sure that the value of the 3 fields is equal to 12. Here's my...
2
by: Targa | last post by:
Im using the code below to pop up a window: It works fine except for that in the titlebar, my domain name is listed before the page title like below: http://mydomain.com - MyPopupwindowname -...
3
by: ATS | last post by:
I'm trying to set up a slide show on a web page using Javascript. Here is the code I have so far: <script language="javascript"> alert("**in test area 1"); slides = new Array(); slides =...
0
by: gunimpi | last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431 ******************************************************** VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help wanted...
2
by: rookiejavadude | last post by:
I'm have most of my java script done but can not figure out how to add a few buttons. I need to add a delete and add buttong to my existing java program. Not sure were to add it on how. Can anyone...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
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...
0
agi2029
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,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.