473,549 Members | 3,048 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

grabbing table data with php

19 New Member
Hi,
I modified the code on the following page:
http://www.thescripts.com/serverside...ses/index.html

this is my code:
<?
/* declare some relevant variables */
$DBhost = "localhost" ;
$DBuser = "myusername ";
$DBpass = "password";
$DBName = "webimages" ;
$table = "artwork";

mysql_connect($ DBhost,$DBuser, $DBpass) or die("Unable toconnect to database");
@mysql_select_d b("$DBName") or die("Unable to select database $DBName"); $sqlquery = "SELECT * FROM $table WHERE dateCreated = '2002'";
$result = mysql_query($sq lquery);
$number = mysql_numrows($ result);

$i = 0;

if ($number < 1) {
print "<CENTER><P>The re Were No Results for Your Search</CENTER>";
}
else {
while ($number > $i) {
$theimage = mysql_result($r esult,$i,"image ");
$thetitle = mysql_result($r esult,$i,"title ");
print "<p><b>imag e:</b> $thename<br><b> title:</b>
$thetitle</p>";
$i++;
}
}
?>


and i get this error message when i try to run the code:

Warning: mysql_numrows() : supplied argument is not a valid MySQL result resource in W:\www\dateCrea ted2001.php on line 21

There Were No Results for Your Search

although this says there are no results, there are several images with datCreated 2002 in the table. The "image" field is a tinyblob. This is my first attempt to pull a query through.
Can anyone please see where i'm going wrong?
thanks,
Diz
Mar 30 '06 #1
3 1477
Banfa
9,065 Recognized Expert Moderator Expert
The php looks fine allthough I would use mysql_fetch_ass oc rather than mysql_numrows and mysql_result so I guess the error must be in the SQL statement.

The is nothing obvious wrong so I would try changing

WHERE dateCreated = '2002'

to

WHERE dateCreated='20 02'

NOTE I have deleted 2 spaces

and running the query directly on the database without going through php or going via phpmyadmin.
Mar 30 '06 #2
Diz
19 New Member
thanks Banfa. I will those changes to the code. but i think i have to use php as what I'm working on is a website, mostly html, but a backend database to store the images in. i've created a few queries using phpmyadmin and mysql, and I've run a similar query directly on the database, but thought i would try and use the example code as i've just linked to the database but haven't managed to pull a query through yet!
Mar 30 '06 #3
Banfa
9,065 Recognized Expert Moderator Expert
What I do to test out new database stuff this:

I have MySql install on my computer at home

I download a backup of the database on the website using PhPMyAdmin

I load it into my home sql server using the 'source' command

I try out any new selects etc at home from the MySql command prompt rather than through a website.

This allows you to work on the MySql statements independently of any other language or interface making it easy and quick to get you SQL right.

Once it is right you can insert it into you PHP.
Mar 31 '06 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

5
2580
by: Joe | last post by:
I need to connect to 10 web sites to grab content from them. I would like to connect to each site simultaneously so that I can obtain the data as fast as possible. I am familar doing this with perl by using parallel sockets or the module LWP-Parallel. So what would be the best method to do this in php? Sockets, forks? Also, if...
4
1299
by: InvisibleMan | last post by:
Hi, Thanks for any help in advance... I'm wondering if anyone knows how or has the resource for graabing a users email address without them knowing? Before I hear all the 'Its not ethical' blurb - I know and my use is legitimate... I am build an e-commerce store and as well as grabbing the users IP at point of sale, i think it would be...
0
1095
by: wellnesseducation | last post by:
I have enabled session stating on an application I have written by modifying the web.config to write to a SQL database, after I ran the state script with the query analyzer provided by the .NET framework installation (I think it is installsqlstate.sql). The session data appears to be writing correctly, however I have some questions...
1
1881
by: Aliza Klein | last post by:
Hi. A client of mine has a website with a standard "Contact Us" form page with name, address etc. The information is currently sent via email to the client and is then data entered into their Access (2000) system. I am sure there is a better way of doing this.
4
1384
by: darrel | last post by:
I have a contact form that a person submits to the server. In ASP, you'd make a page, post the form to another page, which would grab the values and do somethign with them. in ASP.NET, it appears that you grab the values directly from the form objects on the postback. Here's our problem:
3
1276
by: Darrel | last post by:
I'm writing out my own Table via codebehind. Each row has an INPUT TYPE="TEXT" that I am writing out dynamically as well. I want people to be able to update this text, then, upon submit, I'm going to walk through each one to update the DB. How do I access these form fields from the codebehind? I know I can put a RUNAT="SERVER" on this and...
0
821
by: darrel | last post by:
I'm using a string builder to build an HTML table using data from a dataset. Normally, I'd grab the data, fill a data set with it, then access the fields as such: ds.Tables(0).Rows(0)("fieldName") Easy enough. Now, this time, I'm trying to do the same, but I'm implementing pageData as well. My initial thought is that I can't do this...
4
1591
by: bwalke | last post by:
Help Needed Please!!! With a VB.NET web application, I am trying to save pictures and files to a directory on the web server. However, the web server is not grabbing the Posted Files. For example: File1.PostedFile Is Nothing = True. Like it always seems to go, this page and the File1.PostedFile method works perfectly fine on my development...
0
1580
by: .Net Sports | last post by:
I've been looking everywhere, but i can't locate any functions, or articles on the net or my resources, on how to open a file using vb.net, and then grabbing certain parts of the file, and putting it into a useable variable. I know there are functions like Split, Len, Trim, etc., but I have found nothing as far as the sequence for the syntax....
0
7718
Oralloy
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. ...
0
7809
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 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...
0
6041
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5368
isladogs
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...
0
5088
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...
0
3498
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3480
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1058
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
763
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.