Jump to content

XenoPhage

Members
  • Posts

    99
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

XenoPhage's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. [!--quoteo(post=357094:date=Mar 21 2006, 04:13 PM:name=brokenhope)--][div class=\'quotetop\']QUOTE(brokenhope @ Mar 21 2006, 04:13 PM) [snapback]357094[/snapback][/div][div class=\'quotemain\'][!--quotec--] Now, the userid is easy, I will set it to int, auto_increment. The thing's that I dont know how I should set is pretty much everything else, usually I would set them all to Text... username will contain the persons username userpass will contain a md5'ed version of the persons password userjoindate will contain a timestamp of the date they joined userpageviews will contain a numerical value of the number of pages they have viewed userlastlogin will contain a timestamp of the date they last logged in userlevel will contain a numberical value to the id of their userlevel (corresponding in the userlevel/ privilages table) useravatar will contain a url, maybe an id to their avatar userfavorites will contain an array, or a string (to be "explode()"'ed into an array) of the users favorite pages on the site [/quote] Well, don't just set then for text unless you have no interest in growth .. :) I'd do the following : [code] CREATE TABLE mytable (id   INTEGER UNSIGNED  AUTO_INCREMENT,                                     username  CHAR(15) NOT NULL,                                     password   CHAR(32) NOT NULL,                                     joindate     DATETIME NOT NULL,                                     pageviews  INTEGER DEFAULT 0,                                     lastlogin     DATETIME NOT NULL,                                     level          TINYINT NOT NULL DEFAULT 0,                                     avatar        INTEGER,                                     PRIMARY KEY (id)); CREATE TABLE avatar (id   INTEGER  UNSIGNED  AUTO_INCREMENT,                                   location  CHAR(255) NOT NULL,                                   PRIMARY KEY (id)); CREATE TABLE favorites (id  INTEGER  UNSIGNED  AUTO_INCREMENT,                                      url  CHAR(255) NOT NULL,                                      userid INTEGER UNSIGNED NOT NULL,                                      PRIMARY KEY (id)); [/code] Now, what I've done above is how I'd structure it based on what you told me.. I definitely wouldn't be placing the favorites into an imploded array.. Let SQL do the work for you.. As for queries, that depends on what you need..
  2. [!--quoteo(post=356963:date=Mar 21 2006, 08:58 AM:name=dalmaca)--][div class=\'quotetop\']QUOTE(dalmaca @ Mar 21 2006, 08:58 AM) [snapback]356963[/snapback][/div][div class=\'quotemain\'][!--quotec--] but now ive moved over to my new webserver im gettin error cron mails.. saying " php: error while loading shared libraries: libmysqlclient.so.12: cannot open shared object file: No such file or directory" is this something ive done or there end ? [/quote] This would be their end. Sounds like they don't have the shared_compat libraries installed.
  3. [code] <html> <head> <title>Homework Administration- Delete Homework</title> <META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW"> </head> <body> <?php $conn = mysql_connect("localhost","cortez","165745"); //now choose the database to use mysql_select_db("cortez_photoalbums"); $id = $_GET['id']; // retrieve id passed via URL if (isset($id)) {     $query = "DELETE FROM images WHERE id = '$id' ";     $result = mysql_query($query); } $getimages = mysql_query("SELECT * FROM images ORDER BY id DESC"); while($r=mysql_fetch_array($getimages)) { extract($r); //remove the $r so its just $variable     echo("<hr>   Image: <image src='$_POST[imageurl]' height=\"50\" width=\"50\"><br>     Id: $id <br>     Date: $date<br>     <a href='". $_SERVER['PHP_SELF']. "?id=$id'>delete</a>"); } ?> </body> </html> [/code] You missed closing the while() loop.. Above passes a php lint test.
  4. [!--quoteo(post=355482:date=Mar 15 2006, 04:21 PM:name=PGS JoE)--][div class=\'quotetop\']QUOTE(PGS JoE @ Mar 15 2006, 04:21 PM) [snapback]355482[/snapback][/div][div class=\'quotemain\'][!--quotec--] [code]$days = array(   //read database and if there is an event, of which there should be plenty...        day of event=>array('# . $id','linked-day' //I have no clue what this does), );[/code] [/quote] Hrm.. array of arrays.. Good fun! [code] $days = Array(); while ($line = mysql_fetch_array($result)) {    $days[$line[0]) = Array($line[1], $line[2]); } [/code] For my little example, $line[0] is the day of the week, $line[1] is '# . $id' and $line[2] is 'linked-day' .. All of those values are returned from the database.. I think that gives you what you want?
  5. [!--quoteo(post=355481:date=Mar 15 2006, 04:19 PM:name=HoTDaWg)--][div class=\'quotetop\']QUOTE(HoTDaWg @ Mar 15 2006, 04:19 PM) [snapback]355481[/snapback][/div][div class=\'quotemain\'][!--quotec--] [code] <?php $conn = mysql_connect("localhost","cortez","165745"); //now choose the database to use mysql_select_db("cortez_photoalbums"); $id = $_GET['id']; // retrieve id passed via URL if (isset($id)) {     $query = "DELETE FROM images WHERE id = '$id' ";     $result = mysql_query($query); } $getimages = mysql_query("SELECT * FROM images ORDER BY id DESC"); while($r=mysql_fetch_array($getimages)) { extract($r); //remove the $r so its just $variable     echo("<hr>   Image: <image src='$_POST[imageurl]' height=\"50\" width=\"50\"><br>     Id: $id <br>     Date: $date<br>     <a href='". $_SERVER['PHP_SELF']. "?id=$id'>delete</a>"); </body> </html> [/code] [/quote] You didn't close out the php code.. You need to add ?> just before the </body> statement..
  6. [!--quoteo(post=355476:date=Mar 15 2006, 04:10 PM:name=brown2005)--][div class=\'quotetop\']QUOTE(brown2005 @ Mar 15 2006, 04:10 PM) [snapback]355476[/snapback][/div][div class=\'quotemain\'][!--quotec--] can anyone tell me how to get this to work below please:- header('location: '.$config_url.'/files/url.php?id='.$random_array['blocks_id'].''); [/quote] Can you explain what you're tryin to go? Are you sure all those variables are set? What results are you getting currently?
  7. What output are you getting? Are you getting errors? Have you included that page anywhere else in the script?
  8. [!--quoteo(post=355445:date=Mar 15 2006, 02:38 PM:name=Arsenal)--][div class=\'quotetop\']QUOTE(Arsenal @ Mar 15 2006, 02:38 PM) [snapback]355445[/snapback][/div][div class=\'quotemain\'][!--quotec--] Oh yeah....that would help. [/quote] Your query failed, or possibly returned no rows. Try your query directly in mysql and make sure it works. Also, add this : [code] $fac_qry  = mysql_query("SELECT name, email FROM ".$SET['pref']."_stor_facility WHERE abbr = '$locat'") or die ( 'MySQL Error : ' . mysql_error() ); [/code]
  9. Ok, this one's not for the light hearted.. :) This is PHP 4.4.0 (gentoo build) Here's some code to start us out (I've cut a LOT out of this) : [code] class Outage {    var outage_id;    var outage_dirty;    function Outage(&$dbconn, $oid = -1) {       if (($oid != -1) && is_numeric($oid)) {          // Load some data from the database          $this->outage_id = $oid;          $this->outage_dirty = false;       } else {          // New outage          $this->outage_id = -1;          $this->outage_dirty = true;       }       // Register a shutdown function       register_shutdown_function( array(&$this, '_check_dirty_flags') );       // Outage creation successful - return true       return true;    }    // Set and/or return the Outage ID    function outage_id($outage_id = -1) {       if (($outage_id != -1) && is_numeric($outage_id)) {          $this->outage_id = $outage_id;       }       // If the current outage ID is -1, this may be a new outage and we need       // to serialize it.       if ($this->outage_id == -1)          $this->_check_dirty_flags();       return $this->outage_id;    }    // Serializes (saves) any changes to the outage    function _serialize_outage() {       // -1 signifies a new outage       if ($this->outage_id == -1) {          // Save this new outage to the database          $this->outage_id = mysql_insert_id();       } else {          // Update this existing outage in the database       }       $this->outage_dirty = false;    }    // Shutdown function    // Checks the flags to see if any serialization is needed    function _check_dirty_flags() {       if ($this->outage_dirty) {          $this->_serialize_outage();       }    } } [/code] Ok, some explanation. I create an instance of the outage class at the beginning of my program. In the direct instance I'm talking about, this is a new outage. The code has a flow something like this (note, in this example, assume that $_REQUEST['outage_id'] is not set : [code]    // Load the defaults    require_once('outage_glob.php');    // Connect to the MySQL database    $sqlhdlr = mysql_connect($DB_HOST, $DB_LOGIN, $DB_PASS)       or die('Could not connect: ' . mysql_error());    mysql_select_db($DB_NAME) or die('Could not select database');    // Create the outage object (all sanitization is handled by the object)    if (isset($_REQUEST['outage_id'])) {       $outage_obj = new Outage($sqlhdlr, $_REQUEST['outage_id']);    } else {       $outage_obj = new Outage($sqlhdlr);    }    // Set a bunch of stuff up in the outage    $outage_obj->mymethod('stuff');    // Now we display the outage id    print $outage_obj->outage_id();    // and exit    exit; [/code] The behaviour sought here is for the outage to have been serialized when $outage_obj->outage_id() was called, and when the code exits, the shutdown function will see the outage_flag as false, thus not bothering to serialize the outage again. However, for some reason, it sees the flag as dirty when the shutdown function is called, and it serializes again. This wouldn't be so bad, but it also sees the outage_id as -1, so it thinks it's a new outage. Can PHP handle this? Am I doing something wrong here? I can always change my program slightly to call the serialization function just before exiting, but I was hoping to add some additional functionality and check for user aborts as well. I wanted to get this working first, though.. HELP! Thanks!
  10. [!--quoteo(post=354920:date=Mar 14 2006, 10:53 AM:name=cnl83)--][div class=\'quotetop\']QUOTE(cnl83 @ Mar 14 2006, 10:53 AM) [snapback]354920[/snapback][/div][div class=\'quotemain\'][!--quotec--] Anyone jack with scorm? I cannot figure how the LMS pulls the data. Say if my score field is named SCORM, how it tells the LMS the the actual score field is name $SCORE. SCORM is the crappiest system in programming yet! [/quote] Are you referring to the Sharable Courseware Object Reference Model? Is this even PHP related?
  11. [!--quoteo(post=354865:date=Mar 14 2006, 08:03 AM:name=chuddyuk)--][div class=\'quotetop\']QUOTE(chuddyuk @ Mar 14 2006, 08:03 AM) [snapback]354865[/snapback][/div][div class=\'quotemain\'][!--quotec--] im just getting stuck with how to make it add the "1" when the radio button is selected and submited any ideas? [/quote] I'm not 100% sure of what you want.. Post what code you currently have, as well as the database design, and maybe we can help more.. As for how to detect if a radio button is selected, you need to do something like this : [code] <input type='radio' name='newstype' value='1'>Business</input> <input type='radio' name='newstype' value='2'>Student Union</input> <input type='radio' name='newstype' value='3'>Employer News</input> <input type='radio' name='newstype' value='4'>16-19 Years</input> <input type='radio' name='newstype' value='5'>Adult News</input> [/code] And then on the php side : [code] if ($_REQUEST['newstype'] == 1) {    // Handle business news here } else if ($_REQUEST['newstype'] == 2) {    // Handle student union news here } else if ($_REQUEST['newstype'] == 3) {    // Handle employer news here } else if ($_REQUEST['newstype'] == 4) {    // Handle 16-19 years news here } else if ($_REQUEST['newstype'] == 5) {    // Handle adult news here } else {    // Handle exceptions here (nothing was chosen!) } [/code]
  12. [!--quoteo(post=354476:date=Mar 13 2006, 07:38 AM:name=Essjay_d12)--][div class=\'quotetop\']QUOTE(Essjay_d12 @ Mar 13 2006, 07:38 AM) [snapback]354476[/snapback][/div][div class=\'quotemain\'][!--quotec--] The data was inserted using an insert form through php using a <textarea name="F_Review"></textarea> tag. How can I get php to recognise or produce it in two paragraphs? [/quote] HTML will ignore \n (linefeed) ... So you need to convert those to <br /> .. Try using nl2br() before displaying the info from the database. Or, it may be possible that when you stored the data that was submitted, something you did stripped the line feeds.. Can't tell that unless you post that part of the code.
  13. [!--quoteo(post=353605:date=Mar 10 2006, 08:11 AM:name=Cell0518)--][div class=\'quotetop\']QUOTE(Cell0518 @ Mar 10 2006, 08:11 AM) [snapback]353605[/snapback][/div][div class=\'quotemain\'][!--quotec--] Example (from Gallery 2) $urlGenerator->makeUrl($path)); for this "->", does it mean something like this? $variable "execute and set return value = to $variable" makeURL(to "$path variable" in this case)? Just trying to understand some of the more complicated code in Gallery. Thanks, Chris [/quote] $urlGenerator is an object, makeUrl is a method for that object. It's basically calling the makeUrl method with an argument of $path. It doesn't appear that this is returning anything as there's no additional variable. It may be that the method creates the URL and stores it in an internal member variable.
  14. [!--quoteo(post=353306:date=Mar 9 2006, 12:01 PM:name=Jerry1)--][div class=\'quotetop\']QUOTE(Jerry1 @ Mar 9 2006, 12:01 PM) [snapback]353306[/snapback][/div][div class=\'quotemain\'][!--quotec--] That seems to have worked. What else can I do to make sure my employer can not back track anything to find what web-sites i have been on? [/quote] Umm.. what exactly does this have to do with PHP and/or MySQL?
  15. Hey all, I have a select multiple box. In that box are a number of options. The user chooses options and then the back end saves them to a database. This all works fine. Now, the user needs to edit those choices. I pull the data from the database, and display the relevant selections to the customer. Again, that same select multiple box, but this time with the previous selections highlighted. The customer changes the selection and submits it again. This is the part I'm curious about. Right now, I take that input, plus the values from the database, and I build a hash. If the value is in the database *and* was submitted, I do nothing. If the value is in the database and not submitted, I delete it from the database. And lastly, if it was submitted but not in the database, I add it to the database. My question is, is there a more efficient way to do this? Are there any tricks or php functions that can do this work easily? The code is fairly simple to do this, but I think I'm wasting a ton of memory because, in the end, I wind up with 3 lists that have roughly the same data depending on how many changes there were.. Any thoughts?
×
×
  • 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.