|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now! |
|
#1
|
||||
|
||||
|
Hi guys,
I have a table in my database that store my stores products. I want to perfrm a check that the product id actually exists before continuing on with the script. If not I want to redirect the user. I tried the following code but all I get is a blank page: PHP Code:
|
|
#2
|
|||
|
|||
|
Remove echo(" and just put ". I think you can't have ( there. Also, turn error reporting on.
|
|
#3
|
||||
|
||||
|
You should get a blank page. Because you need to echo something out saying product exists or not. There is no print/echo in the code in the while loop!
|
|
#4
|
||||
|
||||
|
Quote:
You can have parenthesis in echo. |
|
#5
|
||||
|
||||
|
"Remove echo(" and just put ". I think you can't have ( there. Also, turn error reporting on."
?? But I dont have 'echo' I have: header("Location: ../index.php"); exit(); |
|
#6
|
||||
|
||||
|
I added this but still get blank page?
ini_set ('display_errors', 1); // Show errors, if any error_reporting (E_ALL & ~E_NOTICE); |
|
#7
|
||||
|
||||
|
Listen, is the page being redirected to index.php? If not and you get a blank page then thats what should happen since there is no echo in your code except the error reporting one.
|
|
#8
|
||||
|
||||
|
No its not being redirected... It should be as I ma entering a product id that doesnt exist.
I even tried this and still got a blank page: // make sure the product id exists - if not redirect to main page if (!isset($r['product_id'])) { echo"assasasas"; } |
|
#9
|
||||
|
||||
|
So if you are being redirected correctly, then there must be something wrong with the page (index.php) you are redirecting to.
|
|
#10
|
||||
|
||||
|
Quote:
EDIT: I realised you said its not redirecting. It means the if statement doesn't evaluate to true. So maybe your query doesn't execute correctly. When test product ids echo out the $_GET and see if it contains your id. Last edited by JavaNinja : May 8th, 2008 at 04:55 PM. |
|
#11
|
||||
|
||||
|
the get variable does work as when i remove the check to see if it exists and there is a valid id in the url my product info page displays correctly.
|
|
#12
|
||||
|
||||
|
You can't use the Location, because data has already been sent by the php script. Use this instead:
echo '<meta http-equiv="refresh" content="1;URL=yourpage.php" />';
__________________
Raid1 in XP Pro My open source projects: ------------------------ Blobber - Add images as blobs to SQL Server ------------------------ |
|
#13
|
||||
|
||||
|
Quote:
Try this: PHP Code:
|
|
#14
|
||||
|
||||
|
Still getting a blank page when an invalid id is used:
// make sure the product id exists - if not redirect to main page if (!isset($r['product_id'])) { echo '<meta http-equiv="refresh" content="1;URL=index.php" />'; } |