Jump to content

waddledoo

Members
  • Posts

    38
  • Joined

  • Last visited

    Never

Everything posted by waddledoo

  1. Okay that killed one of my errors, but I still get the username error.
  2. Okay I changed the lines to: <form id="f6" action="<?php echo $_SERVER['PHP_SELF']?>" method="post" onsubmit="return weCheckForm(this)"> <input id="e1" class="cc35" type="submit" name="submit" value="Login"> And I also tried changing //$username = mysql_real_escape_string($_POST['username']); $username = $_POST['username']; Absolutely nothing has changed. I still get all the same errors. EDIT: I'm using a web creator program for the design of the site itself, and the form was added using that. Should I add it in myself through HTML?
  3. It's in the same file. I tried adding "<?php echo $_SERVER['PHP_SELF']?>" <input id="e4" class="cc34" type="text" name="username" title="username" size="23"> = "<?php echo $_SERVER['username']?>"<br> <label id="e3" class="cc33" for="e2"> Password </label> <input id="e2" class="cc34" type="password" name="password" title="password" size="23"> = "<?php echo $_SERVER['password']?>"<br> <input id="e1" class="cc35" type="submit" title="submit" value="Login"> = "<?php echo $_SERVER['Login']?>" But it just gave me more errors along the same lines (Notice: Undefined index: etc...)
  4. I am attempting to create a login page, but my script is giving errors in relation to the forms. Involved PHP: $username = mysql_real_escape_string($_POST['username']); if ($_POST['submit']=='Login') { $md5pass = md5($_POST['password']); $sql = "SELECT id,username FROM members WHERE username = '$username' AND password = '$md5pass'"; //etc etc... Involved HTML: <form id="f6" action="" method="post" onsubmit="return weCheckForm(this)"> <fieldset id="e6" class="cc32"> <label id="e5" class="cc33" for="e4"> Username </label> <input id="e4" class="cc34" type="text" name="username" title="username" size="23"><br> <label id="e3" class="cc33" for="e2"> Password </label> <input id="e2" class="cc34" type="password" name="password" title="password" size="23"><br> <input id="e1" class="cc35" type="submit" title="submit" value="Login"> </fieldset> </form> Errors received: Notice: Undefined index: username in C:\(etc etc...) on line 4 Notice: Undefined index: submit in C:\(etc etc...) on line 6 Now I know that the problem is username and submit are undefined. However, I do not know how to define them in relation to the forms.
  5. Ah thankyou. More and more I see PHP is like C++. I was used to coding in python hehe
  6. I found a better way to accomplish what I wanted. I still don't understand what was wrong with my previous code, but the new code works perfectly: do { $end = true; $idNum = rand(1,10);//rand(1,999999); $idNumTx = (string)$idNum; $testExists = mysqli_query($link,"SELECT idNum FROM test3 where idNum='$idNum'"); $num = mysqli_num_rows($testExists); if ($num!=0) { $end = false; } } while(!$end); This code now queries the random number directly from the table, and will only complete the loop if the query returns nothing (if the #ofrows returned is 0) This thread can be marked as solved, or deleted.
  7. I am trying to place a unique number into a mysql table. Currently, my code generates a random number, then is supposed to scan through the table for that number. If the code finds that number already in the table, it generates a new random number and repeats the process. I have commented my code for the purpose of this help forum: $result = mysqli_query($link,"SELECT * FROM testTable"); do { $end = true; //prepares end of loop $idNum = rand(1,10); //rand(1,999999); <-- for testing purposes I have reduced the number generated $idNumTx = (string)$idNum; //loop through the rows while ($row = mysqli_fetch_assoc($result)) { if ($row['idNum'] = $idNum) //check if the random number equal to this row { $end = false; //prep end of loop repeat echo $idNumTx; //display rand number that failed for testing purposes echo " NO! "; //display error for testing purposes } } } while(!$end); I know I must be doing something wrong, as when I run this, it runs the if statement within the while loop always executes, and I get an output like: 1 NO! 1 NO! 1 NO! 1 NO! 1 NO! 1 NO! 5 Win Win is when it places the value before it, in this case 5, into the table. However, the value of 5 might already be in the table and it doesn't seem to matter. I execute the code multiple times, and it seems to increase the number of "# NO!" almost (but not every) time. However, each time ALL of the "# NO!" are the same #, and the "# Win" just seems to be random (as it should be, but not unique). Checking the table after shows me random numbers between 1 and 10 (as it should) in the correct field, but the are not unique. (Ex/ Both row 1 and 5 could have the same value, say 6) I'm hopefully doing something simple wrong, so someone please point it out to me
  8. Wow. I can't believe it was so simple, but it seems I just fixed the problem. My code for actually locating the server was as follows: ; The root of the PHP pages, used only if nonempty. ; if PHP was not compiled with FORCE_REDIRECT, you SHOULD set doc_root ; if you are running php as a CGI under any web server (other than IIS) ; see documentation for security issues. The alternate is to use the ; cgi.force_redirect configuration below ; http://php.net/doc-root doc_root = C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs But then I noticed a lack of quotes, so I changed it to: doc_root = "C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs" And I receive no errors. Also under phpinfo() it now displays mysql and mysqli sections that were not there before. I placed an echo into my code to display if everything worked, and I got the echo display. I am so glad it was just some stupid mistake on my part... I didn't want to deal with a complicated solution XD This post can be marked as solved (unless I'm supposed to do that, in which case I haven't a clue how)
  9. As for the web server, I thought he meant web host (other than my own computer). As for how I installed PHP, I used the information found on http://www.sitepoint.com/php-amp-mysql-1-installation/ and downloaded the "VC9 x86 Thread Safe" Zip File from http://windows.php.net/download/ I also know that PHP installed, as opening Apache Service Monitor displays Apache/2.2.21 (Win32) PHP/5.3.8 I did not use an installer/msi file EDIT: Btw thanks for your help so far, even if my problem isn't solved yet. It reduces frustration when there is hope XD
  10. This is on my computer (localhost) and not a web server. I haven't tried using a webserver yet. I don't want to commit the money until I am confident I can create what I want, or until there is nothing more I can test without one.
  11. I have made such file to view such information, and it has always displayed this (I included the item "Configuration File (php.ini) Path" as it looks like it may have something to do with the problem): Configuration File (php.ini) Path C:\Windows Loaded Configuration File C:\PHP\php.ini And yes, my settings currently do not hide any extensions. The loaded config file directs me to the file I have been editing, but looking at this now I don't know what (if anything) the one above it means.
  12. It seems I cannot edit my post again. I have read the FAQ described in the edit I made earlier, but it didn't tell me anything I hadn't already tried.
  13. EDIT: I just found http://www.phpfreaks.com/forums/index.php/topic,95378.0.html which is an FAQ on this very problem and am reading it now. I have posted this edit in case anyone views this post as I read the FAQ, and will either delete this post (if the FAQ solves this) or leave it if I require more help. MySQL Version: MySQL Server 5.5 This isn't as much a SQL code problem as it is an accessing MySQL itself. If this should be moved elsewhere, please tell me. I am attempting to connect to MySQL on my own computer through localhost, using the following code (I realize the guidelines state "in a CODE block, and without any PHP variables" but I don't know where else to put this): <?php $link = mysqli_connect('localhost', '[i]username[/i]', '[i]password[/i]'); if (!$link) { $output = 'Unable to connect to the database server.'; include 'output.html.php'; exit(); } if (!mysqli_set_charset($link, 'utf8')) { $output = 'Unable to set database connection encoding.'; include 'output.html.php'; exit(); } ?> However, I get the following error: Fatal error: Call to undefined function mysqli_connect() in C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\test1.php on line 2 I have been searching online for the solution to this for hours now, with no success. I have found many similar problems but no fixes I can find are changing anything (which frustrates me as either I am doing something terribly wrong or have a very bad issue). Yes, I have set up the php.ini file correctly (as far as I can tell) My PHP file is located at "C:\PHP", and below is my code for the extension folder: ; Directory in which the loadable extensions (modules) reside. ; http://php.net/extension-dir ;extension_dir = "C:\PHP\ext\" ; On windows: extension_dir = "C:\PHP\ext" I have un-commented the "php_mysqli.dll", as shown in context with code here: ;extension=php_ldap.dll ;extension=php_mbstring.dll ;extension=php_exif.dll ; Must be after mbstring as it depends on it ;extension=php_mysql.dll extension=php_mysqli.dll ; <-- notice the lack of semicolon... I wish it had been that easy ;extension=php_oci8.dll ; Use with Oracle 10gR2 Instant Client <etc etc...> As for the file "libmysql.dll", it does not exist in my PHP folder anywhere, but is located in the "lib" folder of "My SQL Server 5.5". Attempts to place this in either the PHP folder or in the general system's path (System32 folder) have given me no success. I have also been restarting the server (Apache 2.2) after every change to the php.ini file, or to moving files. If anyone can help with this, or at least redirect me to where I can get help, it would be greatly appreciated. I really hope that I'm just missing something obvious, and feel free to smack me upside the head for it if you find it Thankyou
×
×
  • 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.