PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rating: Thread Rating: 10 votes, 4.50 average. Display Modes
 
Unread Dev Shed Forums Sponsor:
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
  #46  
Old September 16th, 2004, 12:29 PM
StanleyGuy StanleyGuy is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 134 StanleyGuy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 34 m
Reputation Power: 4
#44 - How do I make a PHP CRON job run?

Most server hosts these days have CRON control panels and you can setup the time and frequency of how often you want it to run. Usually there is an obvious pull down menu or descrptions of how to set time.

Then there is usually a box where you enter the command itself. On this line you must first enter 'php' then a space then the full path to the script to run on the server. For example:

php /home/mydomain/public_html/script.php

Also, if your php script uses any includes or tried to open any text files for reading or writing you'll need to include the full path those files as above inside your script.php - ie '/home/etc/etc' even if those files reside in the same directory as the php script your initiallly referencing with the cron job.

Reply With Quote
  #47  
Old September 18th, 2004, 07:23 AM
OliverD OliverD is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Posts: 1 OliverD User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Reducing the number of sql queries

[edit] Posted in the wrong place, sorry. What a bad start

Reply With Quote
  #48  
Old September 24th, 2004, 09:16 PM
Jimmy_Jamal99 Jimmy_Jamal99 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 70 Jimmy_Jamal99 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 4
Php development in wrong category

Hey, this php category is in programming languages, while it should be in scripting languages. You probably dont care, I was just making sure you know

Reply With Quote
  #49  
Old September 25th, 2004, 12:52 AM
wannabe wannabe is offline
=) wannabe?
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Jul 2002
Location: florida
Posts: 2,153 wannabe User rank is Lance Corporal (50 - 100 Reputation Level)wannabe User rank is Lance Corporal (50 - 100 Reputation Level)wannabe User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 21 h 58 m 25 sec
Reputation Power: 8
Send a message via AIM to wannabe Send a message via Yahoo to wannabe
you notice that before HTML programming

Reply With Quote
  #50  
Old September 25th, 2004, 06:59 AM
deltacoder's Avatar
deltacoder deltacoder is offline
slightly insane code guru
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jul 2004
Location: Indianapolis, IN
Posts: 871 deltacoder User rank is Sergeant (500 - 2000 Reputation Level)deltacoder User rank is Sergeant (500 - 2000 Reputation Level)deltacoder User rank is Sergeant (500 - 2000 Reputation Level)deltacoder User rank is Sergeant (500 - 2000 Reputation Level)deltacoder User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 2 h 8 m 36 sec
Reputation Power: 11
Send a message via AIM to deltacoder Send a message via MSN to deltacoder
Quote:
Originally Posted by Jimmy_Jamal99
Hey, this php category is in programming languages, while it should be in scripting languages. You probably dont care, I was just making sure you know


Enough with the nitpicking.

Reply With Quote
  #51  
Old October 7th, 2004, 10:31 PM
rogs rogs is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Posts: 0 rogs User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
dynamic dropdown script missing form_open function

Good clean script.

I copied and pasted the code and got several error messages. Copying in sections and reformating lines cleaned up script.

I don't seem to find the "form_open ()" function per the "print form_open ()" statement. Please provide function or feedback.

Thanks for your valued assistance.

~~~~~~~~~~~~~~

Quote:
Originally Posted by saintp
#41. How do I make a select list/drop down menu autopopulate depending on the value of another select list?

This one must come up three times a day.

Here is real code that I have used to great success; this snippet comes from a system that lets students in some of our chemistry courses do their labs via a PHP app. This snippet is from the administrative-side "edit a lab" script. I've tried to remove all custom functions

PHP Code:
//************** start dynamic drop-down list magic ***************// 
  
print "<script language=\"javascript\"><!--\n"
  
$classes mysql_query("SELECT class FROM classes ORDER BY class"); 
  print 
"var labIDs = new Array(" mysql_num_rows($classes) . ");\n"
  print 
"var labNames = new Array(" mysql_num_rows($classes) . ");\n"
  while (list(
$class) = mysql_fetch_array($classes)) { 
     
$labs mysql_query("SELECT DISTINCT labID FROM duedates WHERE class = $class ORDER BY due"); 
     print 
"labIDs[$class] = new Array(" . (sizeof($labs) + 1) . ");\n"
     print 
"labNames[$class] = new Array(" . (sizeof($labs) + 1) . ");\n"
     
$i 1
     print 
"labIDs[$class][0] = 0;\n"
     print 
"labNames[$class][0] = 0;\n"
     while (list(
$lab) = mysql_fetch_array($labs)) { 
        print 
"labIDs[$class][$i] = '$lab';\n"
        print 
"labNames[$class][" $i++ . "] = '"
        print 
addslashes(mysql_result(mysql_query("SELECT name FROM labs WHERE class = $class AND labID = $lab"), 1)); 
        print 
"';\n"
     } 
  } 
  print <<<
EOJS 
function clean(what) { 
  for (; 
what.options.length 1;) { 
     
what.options[what.options.length 1] = null
  } 


function 
updateLabs(which) { 
  
with (document.forms[0]) { 
     
clean(which); 
     
curClass course.options[course.selectedIndex].value
     for (var 
1labIDs[curClass].lengthi++) { 
       
which.options[which.options.length] = new Option(labIDs[curClass][i] + ". " labNames[curClass][i], labIDs[curClass][i]); 
     } 
  } 

//--></script> 
EOJS;  //************** end dynamic drop-down list magic ***************// 

  
print form_open(); 
  
//replace the old static drop-down tag with a new dynamic one 
  
print "Course: <select name=\"course\" onChange=\"javascript: updateLabs(lab);\">\n";
  
$classes mysql_query("SELECT class FROM classes ORDER BY class")
  print 
"<option value=0 selected>Choose one:</option>\n";
  while (list(
$class) = mysql_fetch_assoc($classes)) {
    print 
"<option value=$class>$class</option>\n";
  }
  print 
"</select><br>\n";
  print 
"Lab: <select name=\"lab\">\n<option value=0>Choose one\n</select><br>\n"//will get filled automagically 


This script dumps all of the requisite data into JavaScript, and then clears and updates the dynamic select list every time the static one is changed. I've used similar code to do the same thing with one static and two dynamic select lists.

Reply With Quote
  #52  
Old October 8th, 2004, 02:12 AM
deltacoder's Avatar
deltacoder deltacoder is offline
slightly insane code guru
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jul 2004
Location: Indianapolis, IN
Posts: 871 deltacoder User rank is Sergeant (500 - 2000 Reputation Level)deltacoder User rank is Sergeant (500 - 2000 Reputation Level)deltacoder User rank is Sergeant (500 - 2000 Reputation Level)deltacoder User rank is Sergeant (500 - 2000 Reputation Level)deltacoder User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 2 h 8 m 36 sec
Reputation Power: 11
Send a message via AIM to deltacoder Send a message via MSN to deltacoder
i'm thinking form_open is another function in the chemistry lab app that is not critical for the demonstration at hand.

Reply With Quote
  #53  
Old October 16th, 2004, 01:35 PM
StanleyGuy StanleyGuy is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 134 StanleyGuy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 34 m
Reputation Power: 4
#45 - Why aren't my Session variables staying set?

1. Check to make sure that all pages begin with session_start() and that all the session variables you are trying to set or access are called within $_SESSION[] such as $_SESSION['username']


2. If you are using redirects anywhere on your pages using the header() function with LOCATION then chances are your session variables may get lost along the way. The way to solve this is anywhere you use a header() redirect, on the line prior to it put:

session_write_close();
//then redirect here

This makes sure your session variable updates are written before the redirect takes place.


3. If you've checked all of the above and you're still losing session variables or even worse they're changing on you to different values and you can't figure out why there is a more insidious problem with session vars and register_globals.

Usually you think of register_globals as an easy way to access GET or POST vars without having to parse through the whole $_GET or $_POST array. Well register_globals effects $_SESSION too, and not just for reading variables but for writing them too!!

This is important because if register globals is turned on, and on the first page of your site you set a session var like:

$_SESSION['fruit']="apple";

Then on some other page of your site afterwards you write:

$fruit="banana";

It sets $_SESSION['fruit'] equal to "banana" without you even using the syntax $_SESSION['fruit'] !!!

This sucks because you now need to be very careful not to write to any normal variables that have the same name as a $_SESSION[] variable, because PHP sort of 'aliases' it over to the session var for reading and writing purposes. Took me a lot of hair pulling to realize this, hopefully it saves you from the same.

Reply With Quote
  #54  
Old November 30th, 2004, 11:10 PM
kabhi kabhi is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 0 kabhi User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
[QUOTE=firepages]#29 Why does my page and/or javascript not work in $browser_type


A - Check ur javascript generated by PHP.Every browser has its DOM specifications.your javascript must be compatible with the DOM of the browser on which you are running ur javascript so that the page don't get rendered.
Use DHTML tags instead of HTML tags in your html page to provide cross browser compatibility so that your pages not get rendered on different browsers.PHP has nothing to do with the page display on the browser.Its only the javascript/html/CSS that decides the layout of your page on different browsers.

check your browser name using navigator.appName and then load ur page according to the browser name/DOM type of the browser.
cheers.....
Abhishek

Reply With Quote
  #55  
Old February 18th, 2005, 09:55 AM
djlosch djlosch is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: miami
Posts: 151 djlosch User rank is Corporal (100 - 500 Reputation Level)djlosch User rank is Corporal (100 - 500 Reputation Level)djlosch User rank is Corporal (100 - 500 Reputation Level)djlosch User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 17 h 32 m 55 sec
Reputation Power: 6
Send a message via AIM to djlosch
for sessions...

it took me forever to figure out how exactly they work, but you can have LOTS of code before your session_start(); the only thing is that NONE OF IT CAN OUTPUT ANYTHING TO THE SCREEN. if it does you'll get the cant send headers info. this means you can set cookies and session vars without using javascript redirects etc

Reply With Quote
  #56  
Old June 19th, 2005, 10:37 PM
edman007's Avatar
edman007 edman007 is offline
Trapped on the forums...help
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: Aug 2003
Location: /Users/edman007
Posts: 4,616 edman007 User rank is Major General (70000 - 90000 Reputation Level)edman007 User rank is Major General (70000 - 90000 Reputation Level)edman007 User rank is Major General (70000 - 90000 Reputation Level)edman007 User rank is Major General (70000 - 90000 Reputation Level)edman007 User rank is Major General (70000 - 90000 Reputation Level)edman007 User rank is Major General (70000 - 90000 Reputation Level)edman007 User rank is Major General (70000 - 90000 Reputation Level)edman007 User rank is Major General (70000 - 90000 Reputation Level)edman007 User rank is Major General (70000 - 90000 Reputation Level)edman007 User rank is Major General (70000 - 90000 Reputation Level)edman007 User rank is Major General (70000 - 90000 Reputation Level)edman007 User rank is Major General (70000 - 90000 Reputation Level)edman007 User rank is Major General (70000 - 90000 Reputation Level)edman007 User rank is Major General (70000 - 90000 Reputation Level)  Folding Points: 67263 Folding Title: Intermediate FolderFolding Points: 67263 Folding Title: Intermediate FolderFolding Points: 67263 Folding Title: Intermediate FolderFolding Points: 67263 Folding Title: Intermediate Folder
Time spent in forums: 1 Month 3 Weeks 3 Days 2 h 34 m 4 sec
Reputation Power: 787
Send a message via AIM to edman007
#46 - I am changing the settings in my php.ini but the changes are not taking affect

1. You MUST restart the server unless php is running as a CGI for the changes to take affect

2. Check the value of "Configuration File (php.ini) Path" in your phpinfo(); page
if the value is a path to a file (gives the full path to the php.ini, including the php.ini part), then make sure that that is the file that you are editing

if php does not give the php.ini part in the path (ie, it gives the path to a folder) then this means that php searched that folder for a php.ini but could not find one, so it is not using the defaults, if you would like to change the settings put a file named php.ini in that folder and edit that

3. You server may be telling php to set new values
in apache for example, you can change the settings with the "php_flag" config option in either your httpd.conf or a .htaccess, check these files if you are running apache to make sure that they are not overriding the settings in the php.ini

if this is happing then the phpinfo(); page will have differing values for master and local in some places (probably the ones you are having trouble setting)

4. You scripts may be changing the settings
check you scripts for calls to ini_set(), that function can set some (but not all) configuration options from the script

again, if this is happing then the phpinfo(); page will have differing values for master and local in some places (probably the ones you are having trouble setting)
__________________
Feed ME

Reply With Quote
  #57  
Old November 4th, 2005, 01:32 PM
bmitchell@2s4e's Avatar
bmitchell@2s4e bmitchell@2s4e is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2005
Posts: 239 bmitchell@2s4e User rank is Sergeant Major (2000 - 5000 Reputation Level)bmitchell@2s4e User rank is Sergeant Major (2000 - 5000 Reputation Level)bmitchell@2s4e User rank is Sergeant Major (2000 - 5000 Reputation Level)bmitchell@2s4e User rank is Sergeant Major (2000 - 5000 Reputation Level)bmitchell@2s4e User rank is Sergeant Major (2000 - 5000 Reputation Level)bmitchell@2s4e User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 5 Days 9 h 7 m 13 sec
Reputation Power: 31
Quote:
Originally Posted by esha
What should I do if I am getting this fatal error:Fatal error: Cannot redeclare <bold>somefunction()</bold> (previously declared in \somewhere\filename.php:line x) in \somewhere\filename.php:line x?

It means you have the same include file in two places.
for example let us say you have a file name index.php

and in index.php:
<php>
include("file1.php");
include("file2.php");
</php>
and then let us say in file1.php:
<php>
include("file2.php");
</php>
then you will get this fatal error. all you need to do is comment out include file2.php inside file1.


As an alternative:
include_once (or require_once)
will only include the file if it hasn't done so already..

Reply With Quote
  #58  
Old November 6th, 2005, 03:52 PM
LinuxPenguin's Avatar
LinuxPenguin LinuxPenguin is offline
fork while true;
Dev Shed God 1st Plane (5500 - 5999 posts)