Jump to content

Tenaciousmug

Members
  • Posts

    159
  • Joined

  • Last visited

Posts posted by Tenaciousmug

  1. I don't know why. I've been debugging this for the past hour. My query function I built will not return anything. It passes the parameters just fine, but when it gets to the bind_param, I personally don't think that part is working since it doesn't update the query string when I debug it and therefore gives me a null when I call for the $stmt->num_rows(); function.

     

    Here is my query that is calling it:

    <?php
    include_once dirname(__FILE__).'/class/Database.php';
    $DB = new Database();
    
    echo  $DB->select('usr_username', 'user_usr', 'usr_id = ?', '', '', 'i', '2', 'username');
    ?>
    

     

    Here is my Database class:

    <?php
    include_once '/../includes/constants.php';
    
    class Database {
        private $cxn;
        private $numResult;
        private $stmt;
        private $row;
    
        function __construct() {
            $this->cxn = mysqli_connect(DB_SERVER, DB_USER, DB_PASS, DB_NAME)
                    or die('Could not connect to the database.');
        }
    
        public function select($rows, $table, $where='', $order='', $limit='', $type='', $input='', $result='') {
            $this->stmt = $this->cxn->stmt_init();
    $query = 'SELECT '.$rows.' FROM '.$table;
    if($where != '') {
    	$query .= ' WHERE '.$where;
    }
    if($order != '') {
    	$query .= ' ORDER BY '.$order;
    }
    if($limit != '') {
    	$query .= ' LIMIT '.$limit;
    }
            $this->stmt = $this->cxn->prepare($query);
    if($where != '') {
    	$this->stmt->bind_param($type, $input);
    }
    $this->stmt->execute();
    $this->stmt->bind_result($result);
    $this->numResult = $this->stmt->num_rows;
    for ($i = 0; $i < $this->numResult; $i++) { // look at when you get up. returning 0 instead of 1!
    	$this->row = $this->stmt->fetch_array(MYSQLI_ASSOC);
    	return $this->row;
    }
    return false; //return an error
        }
    }
    ?>
    

     

    Thanks for any help! I wish the num_rows would return 1 result and not be null.

  2. Okay the reason I'm doing it this way is because I work locally and then transfer them to the production site.

    For some reason, this isn't working even though when I view the page source, it has the right URL, but when it's clicked it goes to a blank page, but when I copy and paste, it goes to the right page.

     

    Anywho, this is what I'm trying:

     

    <?php $homeURL = 'localhost:90/Elvonica'; ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
            "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    
    <head>
    <title>Elvonica</title>
    <meta http-equiv="content-type" content="text/html;charset=utf-8" />
    <link rel="stylesheet" type="text/css" href="<?php echo $homeURL; ?>/template/css/skySpirit.css" />
    

     

    I didn't plug in the rest to ignore it since it's not part of the problem. It's printing: localhost:90/Elvonica/template/css/skySpirit.css, but when it's clicked, goes to blank page. When it is copied and pasted, it goes to the right page.

    I have a feeling you can't include PHP inside a link rel or any sort of that header information.

    If anyone could please help me how to do this, I would appreciate it.

     

    FYI:

    I did have just template/css/skySpirit.css and it worked until I go into a another directory like forums/index.php. Then it tries to go localhost:90/Elvonica/forums/template/css/skySpirit.css and it's not in there obviously. :P

     

    Thank you for anything that you can offer!

    I know how to do the includes with the dirname(__FILE__).

  3. Ok I'm setting the error. I debugged my code and it's catching the phrase in the set_error() function. But it's returning NULL when I try to display it from the display_error() function. These functions are in the form class. I create a new instance of it on the register.php and I'm trying to grab the values. Here is my Form class (only showing the part you need to see):

     

    class Form {
        private $error;
        
        public function set_error($errmsg){
            $this->error = $errmsg;
            return;
        }
        public function display_error() {
            $error = "<p style='color:red;'>".$this->error."</p>";
            return $error;
        }
    }

     

    Then here is my register process:

    if(isset($_POST['submit'])) {
        if(isset($_POST['name']) && isset($_POST['username']) && isset($_POST['password']) && isset($_POST['password2']) && isset($_POST['email']) && isset($_POST['email2']) && isset($_POST['dob']) && isset($_POST['gender']) && isset($_POST['security'])) {
            if ($user->register_user($_POST['name'], $_POST['username'], $_POST['password'], $_POST['password2'], $_POST['email'], $_POST['email2'], $_POST['dob'], $_POST['gender'], $_POST['security'])) {
                $message = "User has been registered successfully.";
            }
            else {
                $message = $form->display_error();
            }
        }
        else {
            $message = "Please fill out all parts of the form!";
        }
    }

     

    It display the $message just fine when I call isset($message), but it won't display it when I assign it the form->display_error() value because it returns NULL.

     

    Thank you!

  4. I am looking for a PHP Programmer who is talented in object-oriented. I need someone to tutor me the whole way through a registration and login system. I want to understand the OOP structure. I have multiple books on it, but I can't seem to convert the $dog = new Dog(); $dog->feed('cookie'); etc. I understand when people put it in those terms, but I need to actually understand how the database.php class works in with the login registration system.

     

    So I'm willing to pay someone to teach me how to build the index.php page to go into a more module-like setup, but not have a fullblown out MVC structure. I just want a simple front-end back-end setup. So a .php file with the class and functions for the user.php so it ties the login/registration under a User class.

    But then I also need to know how to setup a database.php file with the MySQL queries. I see that you usually create one that does all the querying, but what about future things like coding a private messaging system. Does it go in the same Database class? Or do you have multiple database classes? I just need some clear explanations and a up-to-date login/registration tutorial.

     

    I can't find any on the internet that are relatively new so I'm looking to hire someone as a tutor for this. I'll need the setting up of the environment, the database class, the user class, and the working front-end scripts. I also want you to be able to steer me in the right direction after that to go ahead and create other scripts.

    When I learned procedural PHP (been programming it for 5 years now), I learned how to build SO MUCH things off of one single login/registration system script so I'm hoping that's what OOP will allow me to do as well.

     

    You can message me at tenaciousmug@live.com on MSN or Dyloki on AIM.

    Thank you!

    - We can discuss the prices on the messenger. I'm pretty flexible so I don't have to keep buying more and more OOP PHP books that don't teach you the login/registration system either.

     

    And yes, I'm fully aware of some running scripts that provide this for you, but I want to code everything myself.

    Also, I do NOT want to work with frameworks! I'm planning on saving that for later when I actually understand OOP first.

     

    My name is Haley! Thank you.

  5. $query = "INSERT INTO custpackage1000(
    id,
    FirstName,
    LastName,
    Country,
    State,
    City,
    ZipCode,
    Address,
    PayPalEmail,
    PhoneNumber,
    PrimaryEmail,
    WebsiteURL) VALUES (
    '1',
    '$fname',
    '$lname',
    '$country',
    '$state',
    '$city',
    '$zcode',
    '$address',
    '$ppemail',
    '$pnumber',
    '$cemail',
    '$url')";

     

    There. You forgot the address!

    Also, do not insert the id manually. thats what the auto increment is for. so delete the id and the $id from the insert statement.

  6. even if i change it to generate_hash in both places, it still gives me the error message:

    [05-Feb-2012 19:47:31] PHP Fatal error:  Call to undefined function  generate_hash() in /home1/elvonica/public_html/scripts/classes/user.php on line 24

     

    The capitalization isn't what's going on. Because in both places I had generateHash. But it just converted it to lowercase. Now I have lowercase, still same error.

    Anyone?

  7. Ok this is my script so far:

    class User {
    
    function generateHash($password, &$saluti=null) {
    	define('SALT_LENGTH', 15);
    
    	$key = '!@#$%^&*()_+=-{}][;";/?<>.,';
    	if ($saluti=="")
    	{
    		$saluti = substr(hash('sha512', uniqid(rand(), true).$key.microtime()), 0, SALT_LENGTH);
    	}
    	else
    	{
    		$saluti = substr($saluti, 0, SALT_LENGTH);
    	}
    
    	return hash('sha512', $saluti . $key . $password);
    }
    
    function validate_user($username,$password) {
    	$mysql = new Database();
    	$hashedPassword = generateHash($password,'');
    	$ensure_credentials = $mysql->verify_username_and_password($username,$hashedPassword);
    
    	if($ensure_credentials) {
    		$_SESSION['auth'] == "yes";
    		header("Location: index.php");
    	}
    	else
    		return "That was not the correct username or password.";
    }
    
    }
    

     

    It gives me this error:

    [05-Feb-2012 17:14:59] PHP Fatal error:  Call to undefined function  generatehash() in /home1/elvonica/public_html/scripts/classes/user.php on line 24

     

    Can anyone help me solve this?

  8. Ah it's still not working, but I did fix that.

    [15-Jan-2012 12:13:03] PHP Warning:  mysqli_error() expects exactly 1 parameter, 0 given in /home1/elvonica/public_html/intellectproductions/james/search_software.php on line 13

     

    Which is where the result variable is. So it's not returning anything, but when I put that in the sql statement in the phpmyadmin, it gives me the result I want. Of course, I change the LIKE '%{$searchSoftware}%' to LIKE '%hatch%'.

     

    EDIT

    Nvm. I'm dumb. xD I spelled ORDER BY wrong. Thank you!!!!

  9. $sql = "SELECT softwareID,softwareName,softwareType,softwareDesc,softwarePath,ITOnly FROM software WHERE softwareName LIKE '%($searchSoftware)%' ORBER BY softwareName";
    $result = mysqli_query($cxn,$sql) or die(mysqli_error());
    

     

    There is something wrong with my LIKE statement because it's not pulling it since I'm either formatting it wrong or something.

    Can anyone catch it?

  10. I've looked up many tutorials and still can't find an answer. D:

    I see this getting pushed down really far and just wanted to move it back up so maybe someone can still help me?

     

    It's only echoing "software/".

    It's not echoing the file i uploaded, but I checked the "name" attribute in the form and the name it's pulling and they both are the same..

  11. Yeah you're right. It's only showing the target_path and not even the basename variable so it's obviously not grabbing it.

    Ok here is the HTML part for my file upload:

    <input type="hidden" name="MAX_FILE_SIZE" value="100000" />
    Software Upload:<br />
    <input name="softwarepath" type="file" /><br />

     

    And the PHP:

    $target_path = "software/";
    $basename = strtolower(basename($_FILES['softwarepath']['name']));
    
    $target_path = $target_path . $basename;
    echo $target_path;

     

    It won't echo the target_path though..

  12. Ok, I have this working on another page from a long time ago, but it's not working right here: It gets past the if($num == 0) part, but when it's seeing if the files has been uploaded, it's not getting past that and it won't give me my error message too. So I have a feeling it's getting past it, but it's not uploading it into the software/ directory and not inserting it into the database.

    I get no errors in my error_log or my default errors I have set up under the variable, $message.

     

    $target_path = "software/";
    $basename = strtolower(basename($_FILES['softwarePath']['name']));
    
    $target_path = $target_path . $basename;
    $sql = "SELECT softwarePath FROM software WHERE softwarePath='$target_path'";
    $result = mysqli_query($cxn, $sql) or die(mysqli_error());
    $num = mysqli_num_rows($result);
    if($num == 0)
    {
    if(move_uploaded_file($_FILES['softwarePath']['tmp_name'], $target_path))
    {
    	$sql = "INSERT INTO software(softwareName,softwareType,softwareDesc,softwarePath,ITOnly) VALUES('$softwareName','$softwareType','$softwareDesc','$target_path','$ITOnly')";
    	mysqli_query($cxn,$sql) or die(mysqli_error());
    	header("Location: search_software.php");
    }
    }
    else
    {
    $message = "There is already a file with that name.";
    }

  13. $(document).ready(function() {
    $(".alert").click(function() {
    	{
    		var id = $(this).attr("id");
    		alert(id);
    		$(id).dialog();
    		return false;
    	}
    });
    });

     

    Ok it's alerting the id AFTER it alerts an undefined.. so it alerts "undefined" and then "5" or whatever the number may be.

    What am I doing wrong?

  14. Nevermind, PHP changed their way of showing errors. I'm looking at the error_log file. I should have been doing this the whole time. I just didn't know they didn't display them right in the browser anymore.

    Thanks!

    I was adding an extra ")" onto the variables I was creating in the while loop.

  15. Oh wow... I can't believe I did that. I'm sorry. I never did that before. I'm so retarded. xD

    Here is my updated code:

     

    $sql = "SELECT alertID,alertName,alertMessage,activateSubj,activateBody,deactivateSubj,deactivateBody FROM alerts ORDER BY alertName";
    $result = mysqli_query($cxn, $sql) or die(mysqli_error());
    while ($row = mysqli_fetch_assoc($result))
    {
    	$alertID = $row['alertID'];
    	$alertName = stripcslashes($row['alertName']);
    	$alertMessage = stripcslashes($row['alertMessage']));
    	$activateSubj = stripcslashes($row['activateSubj']));
    	$activateBody = stripcslashes($row['activateBody']));
    	$deactivateSubj = stripcslashes($row['deactivateSubj']));
    	$deactivateBody = stripcslashes($row['deactivateBody']));
    
    	echo "<div class=\"alert\" style=\"border:1px solid #000;border-radius:5px;padding:12px;\">";
    		echo $alertID."<br />";
    		echo $alertName."<br />";
    		echo $alertMessage."<br />";
    		echo $activateSubj."<br />";
    		echo $activateBody."<br />";
    		echo $deactivateSubj."<br />";
    		echo $deactivateBody."<br />";
    	echo "</div>";
    }
    

     

    Still giving me a blank screen. I don't understand why no parse errors or anything will pop up like they usually do. It's giving me a rough time debugging my scripts.

    Anyway, the stripcslashes() are there because I had to strip the \ from when I escaped the string when inputting it into the database with real_escape_string().

  16. Ok, the sql seems to  be working fine, but when I go into the while loop, it gives me an internal error 500 and doesn't load anything. It just shows me a blank white screen:

     

    $sql = "SELECT alertID,alertName,alertMessage,activateSubj,activateBody,deactivateSubj,deactivateBody FROM alerts ORDER BY alertName";
    $result = mysqli_query($cxn, $sql) or die(mysqli_error());
    while ($row = mysqli_fetch_assoc($result))
    {
    $alertID = $row['alertID'];
    $alertName = stripcslashes($row['alertName']);
    $alertMessage = stripcslashes($row['alertMessage']));
    $activateSubj = stripcslashes($row['activateSubj']));
    $activateBody = stripcslashes($row['activateBody']));
    $deactivateSubj = stripcslashes($row['deactivateSubj']));
    $deactivateBody = stripcslashes($row['deactivateBody']));
    
    <div class="alert" style="border:1px solid #000;border-radius:5px;padding:12px;">
    	echo $alertID."<br />";
    	echo $alertName."<br />";
    	echo $alertMessage."<br />";
    	echo $activateSubj."<br />";
    	echo $activateBody."<br />";
    	echo $deactivateSubj."<br />";
    	echo $deactivateBody."<br />";
    </div>
    }

  17. Ok I've been staring at this for the past 2 hours and I can't get it. I'm getting super frustrated.

    I'm trying to make a graphic go from image 1 to 2, then 1, then 0 and then back to 1 then 2, etc. So 1,2,1,0,1,2,1,0. I'm starting that process when they click a button called "Start Dancing".. It won't even start dancing at all when I click the button. I don't know what's not reading and what is...

     

    Here is my HTML:

    <p><img id="animation" src="fatcat1.gif" alt="Fat Cat Dancing" /></p> 
    <form>
    <fieldset>
    <button type="button" name="run" onclick="startDancing();">Start Dancing</button>
    <button type="button" name="stop" onclick="clearInterval(begin);">Stop Dancing</button>
    </fieldset>
    </form>

     

    And here is my Javascript:

    	/* <![CDATA[ */
    	var cats = new Array(3);
    	var fatCat = 1;
    	var begin; 
    	cats[0] = "fatcat0.gif"; 
    	cats[1] = "fatcat1.gif"; 
    	cats[2] = "fatcat2.gif";
    
    	function dance() {
    		if (fatCat == 1){
    			++fatCat;
    			$("#animation").src = cats[fatCat];
    		}
    		else if (fatCat == 2){
    			--fatCat;
    			$("#animation").src = cats[fatCat];
    			--fatCat;
    		}
    		else if (fatCat == 0){
    			++fatCat;
    	}
    
    	function startDancing() {
    		if (begin){
    			clearInterval(begin);
    			begin = setInterval("dance()",200);
    		}
    	}
    /* ]]> */

     

    PLEASE help!

  18. Here is my code:

    $sql = mysqli_prepare($cxn,'SELECT userId, salty, password FROM members WHERE userName=?');
    	mysqli_stmt_bind_param($sql,'s',$userName);
    	mysqli_stmt_execute($sql);
    	mysqli_stmt_bind_result($sql,$userId,$salty,$pass);
    	echo $userName;
    	echo $userId;
    	echo $salty;
    	echo $pass;

     

    What is happening is when I plug that query into the phpmyadmin, it pulls the data perfectly.

    But when I put it in my script and do the bind_result() function, it is getting a 0 userId and null salty and pass.... It acts like it's not grabbing any data.

    Am I doing this wrong or is the order I'm doing it wrong? Thanks for the help!

  19. Those are parantheses. o.o

    And I know they mean something in PHP. That's why I'm using them 0.o I don't see your posts useful at all.

    They are just staying obvious things I already have.

    () - parantheses.

    {} - curly braces

    [] - brackets.

     

    Terminology helps when explaining something to people.

  20. 39. if(isset($_POST['submit']))
    40. {
    41. 	if(!(empty($name) && empty($username) && empty($password) && empty($password2) && empty($email) && empty($email2) && empty($gender) && empty($security) && empty($adminpw)))
    42. 	{
    43. 		if($password == $password2)
    44. 		{
    45. 			if($email == $email2)
    46. 			{
    

     

    That is line 39 - 46.

     

    There is no error message. But whenever I submit the form WHILE leaving $name blank, it still goes through and inserts it into the database leaving it blank D:

     

    And then if I put line 41, like this:

    41. if(!empty($name) && !empty($username) && !empty($password) && !empty($password2) && !empty($email) && !empty($email2) && !empty($gender) && !empty($security) && !empty($adminpw))

    It won't go through AT ALL and says "You left a lot of fields blank (my own echo message)".

  21. But NOW, it's not posting the form at ALL. It keeps saying that error message over and over again.

    This is what I have:

    if(!empty($name) && !empty($username) && !empty($password) && !empty($password2) && !empty($email) && !empty($email2) && !empty($gender) && !empty($security) && !empty($adminpw))

×
×
  • 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.