Jump to content

per1os

New Members
  • Posts

    3,095
  • Joined

  • Last visited

Everything posted by per1os

  1. I do not understand why you are using nl2br, that converts newline breaks to <br /> ....now I'm completely confused.
  2. Are you sure you have the printer compiled with your version of php? http://us3.php.net/manual/en/function.printer-open.php it states it might only be in CVS, meaning you need that compiled version of php to have that functionality. http://us3.php.net/manual/en/ref.printer.php and this notes you need PECL installed.
  3. I do not see how $to = &$email; is equal to anything, $email is not global and no parameters are being passed in, perhaps that is where you are going wrong?
  4. your target_path should be /home/cwademus/public_html/%insertuploadfoldernamehere% Your server does not understand the windows paths, even if the server is running on windows (which it seems to be running on *nix if you ask me) so in order to move that uploaded file it needs to be an absolute path on the server. If you are trying to save that file to your local box you would need to download it off the server after it was uploaded to the server. What exactly are you trying to do?
  5. You could always do this instead <?php ob_start(); ?> <!-- javascript code here without any escapes --> <?php $echo .= ob_get_contents(); ob_end_clean(); ?> See if that works.
  6. So basically if a room has 4 beds it can hold 6 people? Wouldn't you just need to do 1 bed per person. If you have 6 people you need 6 beds, if the room has less than 6 beds you need to split the people up into 2 rooms instead of just one. // 6 / 4 = 1.25 should go up to 2 $numRooms = ceil($numStaying / $maxBeds); // round up to the next whole number $perRoom = ceil($numStaying / $numRooms); // Note this needs to be configured for odd numbers $roomNum = array("104", "105", "106"); $i=1; while ($numRooms > $i) { // the - 1 since arrays are zero based $roomArr[$roomNum[($i - 1)]] = $perRoom; } print_r($roomArr); Is that what you are looking for?
  7. <?php $query1="SELECT UserId, format, artist, name, label FROM books WHERE name = \"$getalbum\" order by name asc"; $result1=mysql_query($query1) or DIE(mysql_error()); while ($row = mysql_fetch_array($result1)) { $rows[] = $row; } foreach ($rows as $row) { $query2="SELECT displayimage FROM $dbtable WHERE UserId = ".$row['UserId']." order by UserId asc"; $result2=mysql_query($query2) or DIE(mysql_error()); while ($row2 = mysql_fetch_array($result2)) { echo "UserId: " . $row['UserId'] . " Display Image: " . $row2['displayimage']; } } ?> The reason I put the first one into an array of rows is because I do not think (note this is not fact, just think) that you can do a while mysql_fetch_array inside of a while fetch_mysql_Array due to resource etc. I am not sure but yea you are safer with the way shown above.
  8. $target_path = 'C:\Documents and Settings\Administrator\My Documents\Dreamweaver\uploads\'; SHOULD BE $target_path = 'C:\\Documents and Settings\\Administrator\\My Documents\\Dreamweaver\\uploads\\'; You need to double escape the \ as it is an escape character (IE: if you have $test = "<body bgcolor=\"#000000\">"; the \ makes the quote part of the string, so it "escapes it".
  9. Alright here is my MySQL class as promised, it is very distinct for my needs, I never use persistent connections or any other fancy stuff. However here it is: <?php // mySql database Class class clDB { // Database constructor function clDB($config) { $this->link_id = mysql_connect($config['dbHost'], $config['dbUser'], $config['dbPass']); if (!$this->link_id) { die("There seems to be a problem with the database."); } if (!mysql_select_db($config['dbDatabase'], $this->link_id)) { return $this->error("Unable to connect to database. Please try again later."); } $config = null; } // returns a single array set function fetchArr($sql) { // see if a valid resource was passed in if (!strstr($sql, "Resource")) { $result = $this->query($sql); }else { $result = $sql; } if(mysql_error()) { if (DEV) { return $this->error("SQL: " . $sql . "<br /><br />Error: " . mysql_error() . "<br /><br />Error No:" . mysql_errno()); }else { $this->mailError($sql, mysql_error(), mysql_errno()); return $this->error("There was a SQL error and it has been reported. Sorry for the inconvenience."); } } $ar = mysql_fetch_assoc($result); mysql_free_result($result); return $ar; } // returns a multi-dimension array function fetchMultiArr($sql) { // see if a valid resource was passed in if (!strstr($sql, "Resource")) { $result = $this->query($sql); }else { $result = $sql; } if ($this->numRows($result) <= 1) { return array(0 => $this->fetchArr($result)); } if(mysql_error()) { if (DEV) { return $this->error("SQL: " . $sql . "<br /><br />Error: " . mysql_error() . "<br /><br />Error No:" . mysql_errno()); }else { $this->mailError($sql, mysql_error(), mysql_errno()); return $this->error("There was a SQL error and it has been reported. Sorry for the inconvience."); } } $i=0; while ($row = mysql_fetch_assoc($result)) { $return[$i] = $row; $i++; } mysql_free_result($result); return $return; } // Returns only one column function fetchOneCol($sql) { if (!strstr($sql, "Resource")) { $result = $this->query($sql); }else { $result = $sql; } $return = mysql_fetch_array($result); $return = $return[0]; return $return; } // clears the resource function freeResult($result) { return mysql_free_result($result); } // Sends an email to the admin on an error function mailError($sql, $error, $errorNo) { if (DEV) { print $sql . "<br />" . $error . "<br />" . $errorNo; }else { mail(ADMIN_EMAIL, "SQL Error on your site", $sql . "\n Error Msg: " . $error . "\n Error Number: " . $errorNo, "From: " . ADMIN_EMAIL); } } // Does a correct add slashes. function myAddSlashes($string) { return (get_magic_quotes_gpc()) ? $string : mysql_real_escape_string($string); } // return number of rows function numRows($result) { return mysql_num_rows($result); } //Executes and returns a query function query($sql) { $result = mysql_query($sql, $this->link_id); if (mysql_error()) { $this->mailError($sql, mysql_error(), mysql_errno()); return $this->error("There was a SQL error and it has been reported. Sorry for the inconvience."); } return $result; } // returns the previous insert id function queryReturnID($sql) { $result = mysql_query($sql, $this->link_id); if (mysql_error()) { if (DEV) { return $this->error("SQL: " . $sql . "<br /><br />Error: " . mysql_error() . "<br /><br />Error No:" . mysql_errno()); }else { $this->mailError($sql, mysql_error(), mysql_errno()); return $this->error("There was a SQL error and it has been reported. Sorry for the inconvience."); } } return mysql_insert_id($this->link_id); } // error function function error($msg) { include('error.page.php'); //print $msg; die(); } // close the database connection. function close() { mysql_close(); } } ?> Usage is as follows: <?php // note define('DEV', true); to avoid e-mailing errors. // note define('ADMIN_EMAIL', "[email protected]"); for emailing of errors $config['dbHost'] = "localhost"; // maybe something different than localhost, usually is localhost. I usually store this and include it via a config file $config['dbUser'] = "yourdbuser"; $config['dbPassword'] = "yourdbpass"; $config['dbDatabase'] = "yourdbname"; include('class.mysqldb.php'); // reference to the above code $clDB = new clDB($config); $config = "no data here"; // do this for security reasons to remove all db user/pass. // Usage: // This just returns the result for however you want to use it $result = $clDB->query("SELECT * from tablename WHERE columnname = 'value'"); // returns an array of the above resource and can take either a resource or straight sql $dataArr = $clDB->fetchArr($result); // returns the number of rows the query affected $clDB->numRows($result); //returns an array of the sql $dataArr = $clDB->fetchArr("SELECT * FROM tablename WHERE columnname = 'value'"); // if you are expecting a multi-dimensional array this also takes straight SQL or a resource $multiDataArr = $clDB->fetchMultiArr("SELECT * FROM tablename"); // runs the query and returns the auto increment id $clDB->queryReturnID("INSERT INTO tablename colname1, colname2 VALUES('value1', 'value2')"); // Just grabs one column, this does not check for multiple columns, so I would not suggest trying it $column = $clDB->fetchOneCol("SELECT columname FROM tablename WHERE columnname = 'somevalue'"); // Finally the myAddSlashes(); for prevention of SQL Injection $sql = ""INSERT INTO tablename colname1, colname2 VALUES('value1', '".$clDB->myAddSlashes($_POST['postdataname'])."')"; // The rest of the functions are really internal to the class. ?> Questions, suggestions let me know. This works great for my uses =)
  10. Is that so, than I guess I am a load of crap, I usually don't use the date/time column attiribute int(11) with the unix time stamp is soo much easier =) My bad for leading this person astray.
  11. Should be under the Javascript/html forum.
  12. You can't after 5 minutes, just create a new message with the code.
  13. You have to set to which one you want, usually xhtml Strict (1.0 maybe) was the hardest one to pass. Something like that. Search google for html or xhtml validation.
  14. <?php ob_start(); echo "This is outputted to the browser YAY!"; $browserOutput = ob_get_contents(); ob_end_clean(); $fp = fopen("filename.txt", "w+"); // note look at fopen in php.net to determine what you need here fwrite($fp, $browserOutput); fclose($fp); print $browserOutput; // if you want to show that to the browser ?>
  15. Nothing wrong with that as long as that file's extension is .php. If this is going to be a js file you can set the HEADER('content-type:text/javascript'); to make it appear like a .js file even though it has the .php extension =) <?php header("content-type:text/javascript"); // only required if you want to access file via <script src='etc'> ?> var menu1=new Array() <?php require_once('config.php'); while($sf=mysql_fetch_array($subforums)) { $sfid=$sf["sfid"]; $fid2=$sf["fid"]; $sfname=$sf["sfname"]; print "menu1[0]='<a href=viewsubforum.php?sfid=$sfid>$sfname</a>'"; } ?>
  16. if (!$blabla) { put this ip into banned header("Location: something.php"); } else { echo "hi"; } No sense it setting it == to false it can cause more confusion that way =)
  17. '#".$admit_dates."#'
  18. I think this is considered html, not php. Should be posted in the html forum.
  19. Why did you change that index to uploadedfile instead of fileUp, it should stay the same.
  20. That is just a notice, it does not mean anything other than stating that fileUp is not an index of the array $_FILES. The reason is you have no logic to check if the form was submitted. I would do a check such as: if (isset($_FILES['fileUp'])) { $target = "uploaded/".$_FILES['fileUp']['name']; if(move_uploaded_file($_FILES['fileUp']['tmp_name'], $target)) { echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded"; } else { echo "Sorry, there was a problem uploading your file."; } }else { ?> <form enctype="multipart/form-data" method="POST" action="Upload.php"> <input name="fileUp" type="file"/> <input type="submit" value="Upload File"/> </form> <?php } I would probably just hide the notices if it is working via http://us3.php.net/manual/en/function.error-reporting.php Notices do not necessarily mean anything. It is the warning and FATAL ERRORs that you have to watch out for.
  21. Nope, there is no way. Maybe a tar archive and untaring via ssh on the server. But as far as I know you have to do the permissions manually. You may be able to using the dir class via php.net to print out a list of all files and their permissions and than create a script on the server after you upload the files and run that script off that data you pulled from the old server with the permissions of each file and than use the chmod function to set those file permissions. I am not sure if doing that would work but yea =)
  22. $sql12= mysql_query($sql2,$c0nn); if(mysql_num_rows($sql12) > 0 ){ $arrErrors['email_already_exists'] = 'The E-mail you Entered Already Exists in our Records.'; } } Changed $sql1 to $sql12 in the if statement.
  23. Sounds good.
  24. if the field is date in mysql the date value should be surrounded by #'s IE: WHERE mydate = '#01/10/2007#' Maybe that is where the issue lies?
  25. I do, however my hands are tied (in class right now) I will contact you later tonight at like 9:00pm Mountain Standard Time. No money is needed, it will be fairly simple. email frost [-at-] aeonity [-dot-] com
×
×
  • 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.