Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

IF - else problem NEWBIE 1

Status
Not open for further replies.

krappleby025

Programmer
Joined
Sep 6, 2001
Messages
347
Location
NL
Hi all, im relatively new to php, only two days, lol
i have a small problem, that some of you will know

i have pulled a record from a database using

$result = mysql_query($query)

now, in some cases there wont be a result. as the record does not exist, and i am trying to make the script do one or the other thing, i have tried allsorts including

if (@$result != "")
if ($result != "")

i even tried retrieving the row, and using row variables, but to no avail. what am i doing wrong..

Thanks
 
I'm assuming you're issuing a SELECT query.

IAW , mysql_query() will return either a resource handle or FALSE for a SELECT query. FALSE if there was some error in your query, a resource handle if the query completed successfully. And that's even if the query would return no rows -- a query that returns no rows is still a valid query.

I recommend that you take a look a mysql_num_rows() ( Pass it a valid resource handle (one that is not FALSE) and it will tell you how many rows your query returned.



Want the best answers? Ask the best questions: TANSTAAFL!!
 
Thanks for the help, you managed to help me solve the problem, I have one more,

What is the code for auto page changing

in asp
its
response.redirect ("")

thanks for all your help
 
tried that but the page comes with an error abourt printing header
 
You can't use send a header to the browser (which you are doing with 'header(location: mypage.html);' if you've already sent some output to a page.

Look at your code have you go any echo or print statments that will execute before you send the header. if you have you'll need to restructure your code

MrBelfry
 
ok.. yes there is code that is before, this, but i cannot pull the redirect until the code has finished working,

NOw i n asp i could use response.redirect, in the middle of a page.

Is there nothing like that in php

thanks
 
It's the same with ASP.

The following ASP code:

Code:
<HTML><body>
<% Response.redirect (&quot;foo.txt&quot;) %>


Will generate the error:

Response object error 'ASP 0156 : 80004005'

Header Error

/response_test.asp, line 1

The HTTP headers are already written to the client browser. Any HTTP header modifications must be made before writing page content.

Want the best answers? Ask the best questions: TANSTAAFL!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top