Jump to content

jcbones

Staff Alumni
  • Posts

    2,653
  • Joined

  • Last visited

  • Days Won

    8

Everything posted by jcbones

  1. benefits.php link works because the script resides in the same folder. /placement/ link doesn't work, because you stated that you only have a public_html folder, but it is looking for a placement folder, OR mod-rewrite (which wouldn't work without being setup). The flash banner is looking for port 8888 on your local server, and then for services.php in the public html folder (www), your function errors suggest that your scripts reside in public html(www)/MyCompany/. For the query errors, is your database set up? Do you have the right username? Should you have a password there?
  2. Open up the firefox error console, and see what the javascript errors are.
  3. It can be done, but will require extensive re-working of your code. Give me a bit, and I will try to decipher it further. Have you thought about adding this in as a filter for the results?
  4. Most extensions are listed in the php.ini, but they need to be enabled. Look for this section: ;;;;;;;;;;;;;;;;;;;;;; ; Dynamic Extensions ; ;;;;;;;;;;;;;;;;;;;;;; ; If you wish to have an extension loaded automatically, use the following ; syntax: ; ; extension=modulename.extension ; ; For example, on Windows: ; ; extension=msql.dll ; ; ... or under UNIX: ; ; extension=msql.so ; ; ... or with a path: ; ; extension=/path/to/extension/msql.so ; ; If you only provide the name of the extension, PHP will look for it in its ; default extension directory. ; ; Windows Extensions ; Note that ODBC support is built in, so no dll is needed for it. ; Note that many DLL files are located in the extensions/ (PHP 4) ext/ (PHP 5) ; extension folders as well as the separate PECL DLL download (PHP 5). ; Be sure to appropriately set the extension_dir directive. ; ;extension=php_bz2.dll ;extension=php_curl.dll ;extension=php_dba.dll ;extension=php_exif.dll ;extension=php_fileinfo.dll extension=php_gd2.dll ;extension=php_gettext.dll ;extension=php_gmp.dll ;extension=php_intl.dll ;extension=php_imap.dll ;extension=php_interbase.dll ;extension=php_ldap.dll extension=php_mbstring.dll ;extension=php_ming.dll ;extension=php_mssql.dll extension=php_mysql.dll extension=php_mysqli.dll ;extension=php_oci8.dll ; Use with Oracle 10gR2 Instant Client ;extension=php_oci8_11g.dll ; Use with Oracle 11g Instant Client ;extension=php_openssl.dll ;extension=php_pdo_firebird.dll ;extension=php_pdo_mssql.dll extension=php_pdo_mysql.dll ;extension=php_pdo_oci.dll ;extension=php_pdo_odbc.dll ;extension=php_pdo_pgsql.dll extension=php_pdo_sqlite.dll ;extension=php_pgsql.dll ;extension=php_phar.dll ;extension=php_pspell.dll ;extension=php_shmop.dll ;extension=php_snmp.dll ;extension=php_soap.dll ;extension=php_sockets.dll ;extension=php_sqlite.dll ;extension=php_sqlite3.dll ;extension=php_sybase_ct.dll ;extension=php_tidy.dll ;extension=php_xmlrpc.dll ;extension=php_xsl.dll ;extension=php_zip.dll Remove the semi-colon before the extension. Of course you need to make sure the file exists in the extensions folder.
  5. Not really sure how the logic behind this works, but I understand the problems with this script. Why yes, I would be glad to break it down for you. <?php $age= 60; //set a variable called age, assign an integer of 60 to it. if( isset($_SESSION['logedin']) ) { //if a session index called logedin is set, it could be empty though (most likely is, because the session has NOT been started). $q = mysql_query('SELECT id=`$id`, DATE_FORMAT(`last_activity`,"%a, %b %e %T") as `last_activity`,UNIX_TIMESTAMP(`last_activity`) as `last_activity_stamp`FROM `mymembers`WHERE `$logOptions_id` <> "'.($_SESSION['logedin']).'"'); //run a mysql_query (I don't see a database connection here), then store the Resource in a variable call q. $isonlinecheck = mysql_query($q); //attempt to assign a Resource of a Resource to another variable called isonlinecheck (it won't work). if ($isonlinecheck ="last_activity_stamp + $age "< time()){ //run an if statement which reads: set a string of 'last_activity_stamp + 60' to a variable called isonlinecheck, then see if that string is less than the current timestamp. $isonline = "is <font color='green'>online!</font>";} //set a string to a variable called isonline. else { $isonline = "is<font color='red'> offline!</font>"; } } ?> So, there is a few problems here. 1. You must start a session (if auto session start is not enabled on the server), at the top of the script. 2. You must connect to a database. 3. You are calling the query and storing the result resource, then calling another query on that. I assume that was a mistake, (hey it happens). 4. In the if statement you use a single =, which is an assignment operator, comparison operators is == and ===. 5. Also in the if statement I think you wanted to add age to the last_activity_stamp, but you did it in string syntax which will NOT work. So, I will take my suggestions and incorporate them into the script. Crossing my fingers and hoping that I get it right on the first time around (I doubt it, I'm all jacked up on 5 hour energy ATM). WHOOOOHOOOOOOO. <?php session_start(); /*Please add your database connection details below*/ include('database_connection_file.php'); /*database connection should have already been made*/ $age= 60; //set a variable called age, assign an integer of 60 to it. if( isset($_SESSION['logedin']) ) { //if a session index called logedin is set, it could be empty though (most likely is, because the session has NOT been started). $q = 'SELECT id, DATE_FORMAT(`last_activity`,"%a, %b %e %T") as `last_activity`,UNIX_TIMESTAMP(`last_activity`) as `last_activity_stamp`FROM `mymembers`WHERE `$logOptions_id` <> \''.($_SESSION['logedin']).'\''; $isonlinecheck = mysql_query($q); //Assign a Resource to a variable called isonlinecheck (it won't work). $row = mysql_fetch_assoc($isonlinecheck); //get the row of data from the Resource. if (($row['last_activity_stamp'] + $age)< time()){ //run an if statement $isonline = "is <font color='green'>online!</font>";} //set a string to a variable called isonline. else { $isonline = "is<font color='red'> offline!</font>"; } } ?> I think that is it... if it doesn't work, post back and I'll probably still be up trying to work out all this 5 hour energy. AHHHHHHHHHHHH....
  6. Not trying to make you feel stupid, as this is a common mistake that we see a lot on here. Javascript is ran specifically on the clients machine (end user web browser). PHP is ran specifically on the server (end user never gets php code). You can tell PHP to write anything, but it cannot interact with it in any way other than writing it. If you wish javascript to build the form, you must pass the PHP variables as a javascript array. Now on to more important pertinent stuff. It is actually I who feels a slight bit stupid here. I saw the array.push(), and thought you were trying to insert javascript array's in a php while loop. But, after seeing the whole script (taking time to go through it), I see what it is doing. I also see the problem, which is another common one around here. public function getHotelRooms($hotelID) { $result = mysql_query("select * from rooms where hotel_id = '$hotelID'"); echo "<form name=\"bookingform\" id=\"bookingform\" method=\"post\" action=\"book.php\">"; echo "<input name=\"roomid\" id=\"roomid\" type=\"hidden\" value=\"$roomID\"/>"; echo "<input name=\"roomnum\" id=\"roomnum\" type=\"hidden\">"; This first bit of code explains it all. It is a scope problem. $roomID is not available because it hasn't been passed to the function. Only the hotelID, has been passed. So lets back up to my second to the last post. If room ID comes from the database, then you need to put: echo "<input name=\"roomid\" id=\"roomid\" type=\"hidden\" value=\"$roomID\"/>"; Inside the while loop. ***OR*** IF this variable comes from somewhere else, then you must pass it in the arguments. public function getHotelRooms($hotelID,$roomID) Also, your roomnums are not being passed, because you don't have a value assigned to it. echo "<input name=\"roomnum\" id=\"roomnum\" type=\"hidden\">"; //NO VALUE; Let me know if any of that was hard to understand, I don't have any second languages, all I speak is Southern!
  7. WebStyles is right on target, but I will point out that his code doesn't go deep enough. Consider this: a snippet from your code while ($records = mysql_fetch_assoc($query)) { $alpha[$records['letter']] += 1; ${$records['letter']}[$records['series']] = $records['series']; } This is the first time that $alpha is in your script. You will notice that $alpha resides inside of a query loop. This query loop will never be called, if the database does NOT return any rows. Setting alpa to an empty array before the query loop will solve your problem, as $alpha will then be an array, albeit empty, but it will be an array. PS. I just tried it, you can increment an array that isn't set, but it will throw 2 notices. 1 for undefined variable, the other for undefined offset. In other words (BAD FORM!). My Suggestion in effect $alpha = array(); while ($records = mysql_fetch_assoc($query)) { $alpha[$records['letter']] += 1; ${$records['letter']}[$records['series']] = $records['series']; }
  8. Why you can use a switch() Example switch($where) { case 'product': $where = 1; break; case 'service': $where = 2; break; case 'custom': $where = 3; break; } Now I'm about 99% sure that will work for you, if you drop it between these two lines: } // assemble the sql statement But, if for some reason you run into troubles, post back and I'll get it sorted. PS. don't forget to add your field to the array you specified.
  9. NEVER MIND, just looked closer at the code: It looks as if you are trying to loop through php and insert javascript code that loops through the php values. You CANNOT mix PHP and Javascript like that. If you are pushing a PHP variable value to a javascript array, then you have to build the javascript array before setting it. Javascript has never met PHP, and PHP has never met Javascript. They reside in 2 different worlds, with only non-controlled flight between them.
  10. I suppose your room ID comes from your database? If that is right, then you are trying to set the hidden input value BEFORE any database interaction. Then after that, you assign the room id to a javascript array, populating some kind of roomnum select box. You are going to have to troubleshoot the whole roomid from generation to selection, which runs through that javascript. So, open up the script in your web browser, view source to see if the room id's are set. You may have to highlight the select box, and then view that source, since javascript will not always show up in the regular source.
  11. $time = strtotime($_POST['date']); //get timestamp; $date = date('F d, Y',$time); echo $date; strtotime() date()
  12. After form processing, re-direct to a clean URL.
  13. $query = "select email,mens,womens from newsletters"; $result = mysql_query($query); while ($row = mysql_fetch_assoc($result)) { extract($row); echo "$email - $mens - $womens<BR>";} Look at extract()
  14. If it were me, I would re-write the whole insert block of code as shown above. 1. I do not advocate running queries in loops. This is unneeded overhead, and stress on the mysql server. 2. It can be more efficient since you only need to clean the variables ONCE. <?php if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) { $historyID = GetSQLValueString($_POST['historyconditionID'],'int'); $patientID = GetSQLValueString($_POST['patientID'],'text'); $categoryID = GetSQLValueString($_POST['categoryID'],'int'); foreach($_POST['reasonforcare'] as $value) { $value = (int)$value; $sql[] = "('{$historyID}','{$patientID}','{$categoryID}','{$value}')"; } $insertSQL = "INSERT INTO historyconditions (historyconditionID, patientID, categoryID, conditionID) VALUES " . implode(' , ',$sql); mysql_select_db($database_hordb, $hordb); mysql_query($insertSQL, $hordb) or die(mysql_error()); echo mysql_affected_rows() . ' rows has been inserted into the database!'; }
  15. <?php foreach($_POST['reasonforcare'] as $value) { $sql[] = "('{$value}')"; } $query = "INSERT INTO table (columnName) VALUES " . implode(' , ', $sql); I could help you more if I knew what kind of data we are talking about. ie table names, column names, table relations, etc.
  16. In short, it gets a url that doesn't have a http:// or a www. in front of it. Valid: 9however.com starthere.org tomorrow.ca.org a.us.gov Explain: [a-z0-9]([-a-z0-9]+)?(\.[a-z]{2,3})?(\.[a-z]{2,4}) //pattern [a-z0-9] //pattern starts with a letter, or a number ([-a-z0-9]+)? //capture group 1 second character must be a letter or a number, must be at least one character to capture. (optional parameter '?', which means you don't have to capture this group). (\.[a-z]{2,3})? //capture group 2 starts with a . (dot) followed by 2 to 3 letters (optional, doesn't have to exist). (\.[a-z]{2,4}) //capture group 3 starts with a . (dot) followed by 2 to 4 letters. # = delimiter, as the pattern rest inside of them. i -> after the closing delimiter means it is a case-insensitive match. RegEx is powerful, but difficult to get your mind wrapped around. Great thing to learn though.
  17. When you extend a class, if there is no constructor in the extended class, it will call the constructor of the parent. So the variables will be assigned. BUT, since you assign the variables in the constructor, the properties of MyClass2's protected variable will not be set, but rather will revert to "protected". You can use the functions of the parent, through the child, so there is no need to remake the same functions. Try this: <?php class MyClass { public $public; protected $protected; private $private; protected $varXXX; function __construct() { $this->public = "Public"; $this->protected = "Protected"; $this->private = "Private"; //$this->printHello(); } function printHello() { echo $this->public . "!!!<BR>"; echo $this->protected . "!!!<BR>"; echo $this->private . "!!!<BR>"; } } class MyClass2 extends MyClass { // We can redeclare the public and protected method, but not private protected $protected = 'Protected2'; function changeProtected() { $this->protected = 'Protected2'; } } $class = new MyClass(); echo $class->public; //accessable directly. //echo $class->protected; //not accessable directly, uncomment to see it throw a fatal error. //echo $class->private; //not accessable directly, uncomment to see it throw a fatal error. echo '<br />[Class1]<br />PrintHello function: '; $class->printHello(); $class2 = new MyClass2(); echo $class2->public; //echo $class2->protected; //not accessable directly, uncomment to see it throw a fatal error. //echo $class2->private; //not accessable directly, uncomment to see it throw a fatal error. echo '<br />[Class2 Before Change]<br />PrintHello function: '; $class2->printHello(); //Now let us change the protected variable. $class2->changeProtected(); echo '<br />[Class2 After change]<br />'; $class2->printHello(); ?>
  18. I suppose $row[0] is the primary key (id) and $row[1] is the name. <?php if(mysql_num_rows($reasonforcare) > 0) { while($row = mysql_fetch_row($reasonforcare)) { echo "<input name='reasonforcare' type='checkbox' value='{$row[0]}'/> {$row[1]} \n"; } } Make sure there are no other lines like these BEFORE the code above. <?php $row = mysql_fetch_assoc($reasonforcare); //or $row = mysql_fetch_array($reasonforcare); //or $row = mysql_fetch_row($reasonforcare); If any of these exist before the code provided, then the array pointer will increment to the next index. It will look as if one of the rows isn't being retrieved from the database.
  19. Because array's start at 0, and num_rows start at 1. So you will have to subtract 1 from num_rows in order to get the highest index from the array. <?php $array[] = 1; $array[] = 2; $count = count($array); echo $count; echo '<pre>' . print_r($array,true) . '</pre>'; ?> I used count, but it functions similar to num_rows.
  20. You would make sure the user has voted by checking the user id, IP's can be spoofed, and/or proxied. Which would allow or deny a lot more than just the one user.
  21. You will have to give the actual code you are working with.
  22. I think this is a scope issue. As $sql is not available in the function. Try passing the Database Object to the function.
  23. You cannot access private, or protected directly: This tutorial is one of the best for PHP OOP: http://www.tuxradar.com/practicalphp/6/0/0
  24. <input type="hidden" name="cf_id" value="<?php echo $row[0]; ?>" />
  25. That isn't a multi-dem array, but rather a standard array. No, you can't write an array like that, but you can: <?php $numbers = array_fill(1,4,'under 5'); echo '<pre>' . print_r($numbers,true) . '</pre>';
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.