Webmaster Forum


Go Back   Webmaster Forum > Web Development > Web Design Lobby > Coding Forum
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Coding Forum Problems with your code? Let's hear about it.

Sponsored Reviews   World's Leading Outsourcing Network   V7N Directory

Reply
 
LinkBack Thread Tools Display Modes
Old 08-19-2004, 03:39 AM   #1 (permalink)
Inactive
 
Join Date: 10-29-03
Posts: 249
iTrader: 0 / 0%
Latest Blog:
None

Limit is a jewel in the roughLimit is a jewel in the roughLimit is a jewel in the roughLimit is a jewel in the roughLimit is a jewel in the roughLimit is a jewel in the rough
MySQL help

i have this script:-

[code:1:68334ec501]<?php
$disable = 0;

if ($disable == 1) {
echo "Disabled";
exit;
}
?>[/code:1:68334ec501]

But i need it to look at a MySQL database and see the value in it.

I have a database called 'web' and a table in it called 'test'. In the test table there is two fields 'testname' and 'testvalue'.

and the first entry in the testname field is 'disable' and in test value '0'. However i need the script above so that when the disable value is 1 the disabled message will be displayed. Any ideas?
Limit is offline  
Add Post to del.icio.us
Reply With Quote
Sponsored Links
SEO Hosting by HostGator  Advertise Here  Buy Blog Links
Old 08-19-2004, 06:56 AM   #2 (permalink)
Inactive
 
littleFella's Avatar
 
Join Date: 06-20-04
Location: Ontario
Posts: 3,359
iTrader: 0 / 0%
Latest Blog:
None

littleFella is a splendid one to beholdlittleFella is a splendid one to beholdlittleFella is a splendid one to beholdlittleFella is a splendid one to beholdlittleFella is a splendid one to beholdlittleFella is a splendid one to beholdlittleFella is a splendid one to beholdlittleFella is a splendid one to beholdlittleFella is a splendid one to beholdlittleFella is a splendid one to beholdlittleFella is a splendid one to behold
I have a strong feeling this post is a joke
littleFella is offline  
Add Post to del.icio.us
Reply With Quote
Old 08-19-2004, 06:59 AM   #3 (permalink)
SVB
Inactive
 
SVB's Avatar
 
Join Date: 10-13-03
Posts: 7,481
iTrader: 0 / 0%
Latest Blog:
None

SVB is a web professional of the highest orderSVB is a web professional of the highest orderSVB is a web professional of the highest orderSVB is a web professional of the highest orderSVB is a web professional of the highest orderSVB is a web professional of the highest orderSVB is a web professional of the highest orderSVB is a web professional of the highest orderSVB is a web professional of the highest orderSVB is a web professional of the highest orderSVB is a web professional of the highest order
Send a message via Yahoo to SVB
You need to do an SQL query to get the data from the database
SVB is offline  
Add Post to del.icio.us
Reply With Quote
Old 08-19-2004, 08:27 AM   #4 (permalink)
Inactive
 
Join Date: 10-29-03
Posts: 249
iTrader: 0 / 0%
Latest Blog:
None

Limit is a jewel in the roughLimit is a jewel in the roughLimit is a jewel in the roughLimit is a jewel in the roughLimit is a jewel in the roughLimit is a jewel in the rough
no joke

i did this before but it did not work.

[code:1:c1073b332c]<?php
require "db.php";
$displaysql = "SELECT disable FROM test";
$displayexc = MYSQL_QUERY ($displaysql);
$disable = MYSQL_NUMROWS ($displayexc);

if ($disable == 1) {
echo "Disabled";
exit;
}
?>[/code:1:c1073b332c]
Limit is offline  
Add Post to del.icio.us
Reply With Quote
Old 08-19-2004, 10:36 AM   #5 (permalink)
Inactive
 
Join Date: 10-29-03
Posts: 249
iTrader: 0 / 0%
Latest Blog:
None

Limit is a jewel in the roughLimit is a jewel in the roughLimit is a jewel in the roughLimit is a jewel in the roughLimit is a jewel in the roughLimit is a jewel in the rough
bump
Limit is offline  
Add Post to del.icio.us
Reply With Quote
Old 08-20-2004, 05:48 AM   #6 (permalink)
Inactive
 
Join Date: 10-29-03
Posts: 249
iTrader: 0 / 0%
Latest Blog:
None

Limit is a jewel in the roughLimit is a jewel in the roughLimit is a jewel in the roughLimit is a jewel in the roughLimit is a jewel in the roughLimit is a jewel in the rough
bump
Limit is offline  
Add Post to del.icio.us
Reply With Quote
Old 08-20-2004, 09:15 AM   #7 (permalink)
v7n Mentor
 
hatchet's Avatar
 
Join Date: 10-11-03
Posts: 1,149
iTrader: 0 / 0%
Latest Blog:
None

hatchet is just really nicehatchet is just really nicehatchet is just really nicehatchet is just really nicehatchet is just really nicehatchet is just really nicehatchet is just really nicehatchet is just really nicehatchet is just really nicehatchet is just really nicehatchet is just really nice
SELECT disable FROM test WHERE id = $id
you need to tell it which row to look at.
$disable=mysql_num_rows($displayexc);
hatchet is offline  
Add Post to del.icio.us
Reply With Quote
Old 08-20-2004, 01:14 PM   #8 (permalink)
Inactive
 
Join Date: 10-29-03
Posts: 249
iTrader: 0 / 0%
Latest Blog:
None

Limit is a jewel in the roughLimit is a jewel in the roughLimit is a jewel in the roughLimit is a jewel in the roughLimit is a jewel in the roughLimit is a jewel in the rough
still doesn't work:-

[code:1:972ef73b06]<?php
require "connect.php";
$displaysql = "SELECT * FROM test WHERE value = $value";
$displayexc = MYSQL_QUERY ($displaysql);
$disable = mysql_num_rows($displayexc);

if ($disable == 1) {
echo "Disabled";
exit;
}
?>[/code:1:972ef73b06]
Limit is offline  
Add Post to del.icio.us
Reply With Quote
Old 08-22-2004, 11:33 AM   #9 (permalink)
Inactive
 
Join Date: 10-29-03
Posts: 249
iTrader: 0 / 0%
Latest Blog:
None

Limit is a jewel in the roughLimit is a jewel in the roughLimit is a jewel in the roughLimit is a jewel in the roughLimit is a jewel in the roughLimit is a jewel in the rough
please can someone help me with this as this is the last thing a need before i launch my new website.
Limit is offline  
Add Post to del.icio.us
Reply With Quote
Old 08-22-2004, 05:59 PM   #10 (permalink)
v7n Mentor
 
hatchet's Avatar
 
Join Date: 10-11-03
Posts: 1,149
iTrader: 0 / 0%
Latest Blog:
None

hatchet is just really nicehatchet is just really nicehatchet is just really nicehatchet is just really nicehatchet is just really nicehatchet is just really nicehatchet is just really nicehatchet is just really nicehatchet is just really nicehatchet is just really nicehatchet is just really nice
Try this to see if you're getting anything from the mysql query
<?php
require "connect.php";
$displaysql = "SELECT * FROM test WHERE value = $value";
$displayexc = mysql_query($displaysql);
$disable = mysql_num_rows($displayexc);
echo $disable;
}
?>
hatchet is offline  
Add Post to del.icio.us
Reply With Quote
Old 08-23-2004, 04:18 AM   #11 (permalink)
Inactive
 
Join Date: 10-29-03
Posts: 249
iTrader: 0 / 0%
Latest Blog:
None

Limit is a jewel in the roughLimit is a jewel in the roughLimit is a jewel in the roughLimit is a jewel in the roughLimit is a jewel in the roughLimit is a jewel in the rough
when i do that i get:-

Notice: Undefined variable: value in test.php on line 3

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in test.php on line 5
Limit is offline  
Add Post to del.icio.us
Reply With Quote
Old 08-23-2004, 04:24 AM   #12 (permalink)
SVB
Inactive
 
SVB's Avatar
 
Join Date: 10-13-03
Posts: 7,481
iTrader: 0 / 0%
Latest Blog:
None

SVB is a web professional of the highest orderSVB is a web professional of the highest orderSVB is a web professional of the highest orderSVB is a web professional of the highest orderSVB is a web professional of the highest orderSVB is a web professional of the highest orderSVB is a web professional of the highest orderSVB is a web professional of the highest orderSVB is a web professional of the highest orderSVB is a web professional of the highest orderSVB is a web professional of the highest order
Send a message via Yahoo to SVB
Is connect.php working?
SVB is offline  
Add Post to del.icio.us
Reply With Quote
Old 08-23-2004, 05:00 AM   #13 (permalink)
Inactive
 
Join Date: 10-29-03
Posts: 249
iTrader: 0 / 0%
Latest Blog:
None

Limit is a jewel in the roughLimit is a jewel in the roughLimit is a jewel in the roughLimit is a jewel in the roughLimit is a jewel in the roughLimit is a jewel in the rough
yep, but now i just get:-


Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /test.php on line 5
Limit is offline  
Add Post to del.icio.us
Reply With Quote
Old 08-23-2004, 05:03 AM   #14 (permalink)
Inactive
 
Join Date: 10-29-03
Posts: 249
iTrader: 0 / 0%
Latest Blog:
None

Limit is a jewel in the roughLimit is a jewel in the roughLimit is a jewel in the roughLimit is a jewel in the roughLimit is a jewel in the roughLimit is a jewel in the rough
this is what my table looks like in phpmyadmin:-

Limit is offline  
Add Post to del.icio.us
Reply With Quote
Old 08-23-2004, 05:52 AM   #15 (permalink)
v7n Mentor
 
hatchet's Avatar
 
Join Date: 10-11-03
Posts: 1,149
iTrader: 0 / 0%
Latest Blog:
None

hatchet is just really nicehatchet is just really nicehatchet is just really nicehatchet is just really nicehatchet is just really nicehatchet is just really nicehatchet is just really nicehatchet is just really nicehatchet is just really nicehatchet is just really nicehatchet is just really nice
Then when you connect you are not setting the initial value..
I'm assuming this is some type of list?
And it doesn't look like you have an indexed or unique value in your mysql table. Can you give me an idea of what you want the script to do? What will the page display, before and after this script.. anything else you can think of. Will there be more than one row in that particular table?
hatchet is offline  
Add Post to del.icio.us
Reply With Quote
Old 08-23-2004, 07:56 AM   #16 (permalink)
Inactive
 
Join Date: 10-29-03
Posts: 249
iTrader: 0 / 0%
Latest Blog:
None

Limit is a jewel in the roughLimit is a jewel in the roughLimit is a jewel in the roughLimit is a jewel in the roughLimit is a jewel in the roughLimit is a jewel in the rough
the table layout is going to look similar to phpBB's phpbb_config table with configuration entries.

Basically when the value in that table is 0 the webpage will show normally, but when it is 1 an under maintenance page will be shown.

The script at the very top does this but to get each page to show undermaintenance would require me having to edit every file and put the value 1 in. But i wanted to do it by database as it would be much easier.
Limit is offline  
Add Post to del.icio.us
Reply With Quote
Old 08-23-2004, 08:40 AM   #17 (permalink)
v7n Mentor
 
hatchet's Avatar
 
Join Date: 10-11-03
Posts: 1,149
iTrader: 0 / 0%
Latest Blog:
None

hatchet is just really nicehatchet is just really nicehatchet is just really nicehatchet is just really nicehatchet is just really nicehatchet is just really nicehatchet is just really nicehatchet is just really nicehatchet is just really nicehatchet is just really nicehatchet is just really nice
So you have a start function for each page in an include file? Could you do the select above like this..
SELECT value AS disable FROM tablename WHERE name = website_disable;
then
if($disable = 1) {
echo "Sorry this page is under maintenance";
}
else {
run your start function code
}

Now it's different if you're going to have a true / false for each page.. then you'll need someway to set the page name to send to the function above..
hatchet is offline  
Add Post to del.icio.us
Reply With Quote
Old 08-23-2004, 08:55 AM   #18 (permalink)
Inactive
 
Join Date: 10-29-03
Posts: 249
iTrader: 0 / 0%
Latest Blog:
None

Limit is a jewel in the roughLimit is a jewel in the roughLimit is a jewel in the roughLimit is a jewel in the roughLimit is a jewel in the roughLimit is a jewel in the rough
in each page there was an include to maintenance.php.

Which looked like this;-
[code:1:13a7e60d4c]<?php
$disable = 0;

if ($disable == 1) {
echo "Disabled";
exit;
}
?>[/code:1:13a7e60d4c]
Limit is offline  
Add Post to del.icio.us
Reply With Quote
Old 08-23-2004, 02:31 PM   #19 (permalink)
v7n Mentor
 
hatchet's Avatar
 
Join Date: 10-11-03
Posts: 1,149
iTrader: 0 / 0%
Latest Blog:
None

hatchet is just really nicehatchet is just really nicehatchet is just really nicehatchet is just really nicehatchet is just really nicehatchet is just really nicehatchet is just really nicehatchet is just really nicehatchet is just really nicehatchet is just really nicehatchet is just really nice
So am I correct in assuming that you will need a page by page maintenance script?
If so you can explode the URL (parse_url($PHP_SELF)) of each page and get the filename from that and compare that to a list that you would have to setup in the database.
Hopefully I'm not overcomplicating this
hatchet is offline  
Add Post to del.icio.us
Reply With Quote
Old 08-25-2004, 05:15 AM   #20 (permalink)
Inactive
 
Join Date: 10-29-03
Posts: 249
iTrader: 0 / 0%
Latest Blog:
None

Limit is a jewel in the roughLimit is a jewel in the roughLimit is a jewel in the roughLimit is a jewel in the roughLimit is a jewel in the roughLimit is a jewel in the rough
?
Limit is offline  
Add Post to del.icio.us
Reply With Quote
Go Back   Webmaster Forum > Web Development > Web Design Lobby > Coding Forum

Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP and MySql help daniel0012 Coding Forum 4 06-28-2007 02:48 AM
MySQL help cbolts Web Design Lobby 2 04-09-2004 06:39 AM
PHP/mySQL SN3 Coding Forum 5 02-03-2004 10:38 PM


Sponsor Links
Get exposure! Get exposure! Find Scripts Web Hosting Directory Get exposure! SEO Blog


All times are GMT -7. The time now is 04:49 AM.
© Copyright 2008 V7 Inc