Jump to content

wildteen88

Staff Alumni
  • Posts

    10,480
  • Joined

  • Last visited

    Never

Everything posted by wildteen88

  1. Prehaps you'll have to use pgSQL. But still ask your IT manager whether its possible to use mysql.
  2. Yes you can host a website of your home PC with Apache. However the PC you host it off must have be good a spec CPU/Memory wise a fast internet connection I'd say 10Mbps+, you'll need to have a static IP address and you'll need to allow access to port 80 or forward port 80 fromyour router - if you have one. Then you'll need to get DNS settings to point to your computers IP addy and then you can assign a domain name to your DNS settings. Thats how it basically works. If you dont have a static IP and have a dynamic IP then you'll need rent a static IP addy from your ISP, if they provide them, or from somewhere else. NOTE: I am not an expert at this, but is roughly what you'll want to do. I'd recommend you to stay with your current host.
  3. No not really, however if you want to connect to a  MySQL database you obviously want it installed but tihs wont affect PHP.  You'll probably want ask the IT manager to see whats up. For now run this: [code]<?php phpinfo(); ?>[/code] Look for anythink to do with mysql, about two thirds the way down the page there should be a mysql section. Also scroll to the top of the page and paste whats to the right of the Configure Command box here. Also make sure you're supposed to used mssql/msql database rather tha mysql.
  4. Did you compile (install) PHP? Its not to do with your PHP code at all, but how PHP was installed. Or are you hosted by some webhost? If you didnt install PHP and are renting webspace I would contact your host and ask why you cannot use the mysql functions.
  5. When you complided PHP did you put [i]--without-mysql[/i] command? This the only reason I can think of why its not working with PHP4. As by defualt PHP4 is comipled with the --with-mysql command.
  6. You'll want to use parenthesesis - () and not sqaure brackets []: $assoc = mysql_fetch_assoc($query);
  7. [quote author=BillyBoB link=topic=102689.msg407945#msg407945 date=1154509789] um php is server side you would have to install php and apche and stuff it would be a hastle [/quote] How is it a hastle, its easy. But this is not what sw0o0sh is asking. sw0o0sh you can edit PHP files in the same way. Right click edit with Notepad or if no options are selected. Right click and select Open With > Chose from list. Now select Notepad from the list or any editor of your choice. Or you can download [url=http://www.mpsoftware.dk/]PHP Designer 2006[/url] which you can get for free to edit your PHP files with. If you want to test your PHP script, then simply download Apache 2.0.x (httpd.apache.org) and PHP 5.x xipped package (php.net) and install them on your local PC. Configure Apache to parse the PHP files with the PHP Intepreter and you're set, i'll be able to help with this only needs three lines to be added to the httpd.conf file. Or simply install a pre-packaged version which you can download for free called WAMP server - just google it should be the first result.
  8. griffon if you are with ntl, which I am you can use this in your php.ini: [code]SMTP = smtp.ntlworld.com smtp_port = 25 ; For Win32 only. sendmail_from = [email protected][/code] In the php.ini, make sure you change [email protected] to your ntl email addy. And that you are using the computer connected to the ntl internet connection.
  9. Keep in mind variables should either start of with an underscore (_) or a letter, after that they can contain any number of underscores/letters/numbers etc. [b]Invalid vars:[/b] $ name $1234 $-somename [b]Valid vars:[/b] $__1name2__ $_name1 $name1234 $name Redarrows advice is very good, you should name your variables accordingly.
  10. Use mysql_fetch_assoc as opposed to mysql_fetch_array. So use this: [code=php:0]$q = "SELECT * FROM u_groups WHERE ugroup_id = '$user_group'"; $r = mysql_query($q) or die(mysql_error()); $row = mysql_fetch_assoc($r) {     foreach( $row AS $key => $val )     {         if(strstr($key, "perm_"))         {             //echo "$key, $val<br>"             $_SESSION[$key] = $val;         }     } }[/code]
  11. Please read my thread above. This is what your code should be: [code=php:0]<?php error_reporting(E_ALL); ini_set('display_errors','on'); //connect $conn = mysql_connect("localhost","www2","***") or die ("cannot connect"); $db = mysql_select_db("accu") or die( "Unable to select database"); if (get_magic_quotes_gpc()) {     $orderid = stripslashes($_REQUEST['id']); } $orderid = mysql_real_escape_string($_REQUEST['id']); $query = "SELECT * FROM joborder WHERE id='" . $orderid . "'"; //now send the query to the DB $result = mysql_query($query); echo '<table border="0" cellpadding="0" cellspacing="0">'; // now read the results, i'm assuming your only looking for one row, so $my_row = mysql_fetch_assoc($result) or die ( mysql_error() ); echo "\n<tr><td>" . implode('</td><td>', $my_row) . "</td></tr>\n"; echo '</table>'; ?>[/code]
  12. Okay thats fine. Change: [code]$my_row = mysql_fetch_array($result, MYSQL_ASSOC) or die ( mysql_error() ); print_r($my_row);[/code] with: [code]echo '<table border="0" cellpadding="0" cellspacing="0">'; // now we display the results: $my_row = mysql_fetch_assoc($result) or die ( mysql_error() ); echo "\n<tr><td>" . implode('</td><td>', $my_row) . "</td></tr>\n"; echo '</table>';[/code]
  13. Here is a quick example: [code=php:0]<?php //connect $conn = mysql_connect("localhost", "www2", "*******") or die ("cannot connect"); $db = mysql_select_db("accu") or die( "Unable to select database"); if (get_magic_quotes_gpc()) {     $orderid = stripslashes($_REQUEST['id']); } $orderid = mysql_real_escape_string($_REQUEST['id']); $sql = "SELECT * FROM tbl_name WHERE id_field='$orderid'"; $result = mysql_query($sql, $conn); echo '<table border="0" cellpadding="0" cellspacing="0"> '; // now we display the results: $row = mysql_fetch_assoc($result) {     echo '<tr><td>' . implode('</td><td>', $row) . "</td></tr>\n"; } echo '</table>'; ?>[/code] Make sure you change [b]tbl_name[/b] to the actual table you are going to be querying in the accu database. Also change [b]id_field[/b] field with the name of the field that contains the id. Also you might want to go through the tutorials over at [url=http://www.php-mysql-tutorial.com/]php-mysql-tutorials.com[/url]
  14. It appears the IE oddity AndyB reported above is to do with IE6. IE7 displays it fine, the same as FF.
  15. Do something like this: [code=php:0]$img = $_GET['image']; echo ${'content'.$img};[/code]
  16. PHP is safe. However its down to the programmer to make the system as hack prof as possible. Such as performing proper input validation. For example if you are expecting a numerical value use is_numeric to chekc it is numeric or type cast etc, This is where alot of sites fail on and the reason why most sites get hacked.
  17. Change this: [code]if(mysql_num_rows($query) == '1') {     echo "login successful"; } else {     echo "login failed"; } echo "<br /><br /><b>DEBUG INFO:</b><br /> <code><b>Username</b>: {$username}<br /> <b>Password</b>: {$_POST['password']}<br /> <b>Password Hash</b>: {$password}<br /> <b>MD5 Hash of 'test'</b>: " . md5('test') . "<br /> <b>MD5 Hash TEST</b>: " . ((md5('test') == $password) ? 'passed' : 'failed') . "<br /> <b>Query</b>: {$recieve}<br /> </code>";[/code] to this: [code]if(mysql_num_rows($query) == '1') {     $_SESSION['password'] = $password; //store the users password in a sesions var     $_SESSION['username'] = $username; //store the username in a session var     header('Location: index.php'); } else {     session_destroy();     echo "login failed, please try again"; }[/code] and you should be set to go, fingers crossed
  18. You are using the incorrect password. The password you want to use is test and not tets The DEBUG is what I create with login scripts when they dont work etc. It just shows whats going on.
  19. Okay run this: [code]<?php session_start(); $conn = mysql_connect("localhost", "lov3dco_users", "test") or die('Unable to connect to MySQL'); // select what database to use mysql_select_db("lov3dco_users", $conn) or die('Unable to select database - lov3dco_users'); // get the username from the form, as $username $username = mysql_real_escape_string($_POST['username']); // get the password from the form in md5 $password = md5($_POST['password']); $recieve = "SELECT * FROM users WHERE username='$username' AND `password`='$password'"; $query = mysql_query($recieve, $conn) or die("Unable to peform query - " . mysql_error()); //do the query if(mysql_num_rows($query) == '1') {     echo "login successful"; } else {     echo "login failed"; } echo "<br /><br /><b>DEBUG INFO:</b><br /> <code><b>Username</b>: {$username}<br /> <b>Password</b>: {$_POST['password']}<br /> <b>Password Hash</b>: {$password}<br /> <b>MD5 Hash of 'test'</b>: " . md5('test') . "<br /> <b>MD5 Hash TEST</b>: " . ((md5('test') == $password) ? 'passed' : 'failed') . "<br /> <b>Query</b>: {$recieve}<br /> </code>"; ?>[/code] This time it gives you some debug info.Post the debug info it produces here.
  20. I had a typo before, it should of been this: [code]if(mysql_num_rows($query) == '1'){[/code] Are you getting login successfull now? If you are you can replace: [code]if(mysql_num_rows($query) == '1'){     echo "login successful"; }else {     echo "login failed"; }[/code] with: [code]if(mysql_num_rows($query) == '1') {     $_SESSION['password'] = $password; //store the users password in a sesions var     $_SESSION['username'] = $username; //store the username in a session var     header('Location: index.php'); } else {     session_destroy();     echo "login failed, please try again"; }[/code]
  21. Change [code=php:0]if($rows = mysql_num_rows($query)){[/code] to [code=php:0]if(mysql_num_rows($query) == '1'){[/code] What does that produce?
  22. Okay so something is failing somewhere. Chnage this: [code]if($rows = mysql_num_rows($query)){     $_SESSION['password'] = $password; //store the users password in a sesions var     $_SESSION['username'] = $username; //store the username in a session var $page = "index.php"; header('Location: ' . $page); }else {     session_destroy(); }[/code] to this: [code]if($rows = mysql_num_rows($query)){     echo "login successful"; }else {     echo "login failed"; }[/code] Do you get anythink now?
  23. You have a bunch of echos which is why your code is not working try this: [code=php:0]<?php session_start(); $username = $_POST["username"]; //get the username from the form, as $username $password = md5($_POST["password"]); //get the password from the form in md5 $users = mysql_connect("localhost", "lov3dco_users", "test");     if(!$users) {           echo "<p>Sorry! We could not log you in at this time. Please Try again later!</p>";           exit();         } mysql_select_db("lov3dco_users");  //select what database to use $username = mysql_real_escape_string($username); $password = mysql_real_escape_string($password); $recieve = "SELECT * FROM users WHERE username =  '$username' AND password = '$password';"; $query = mysql_query($recieve) or die("Unable to peform query - " . mysql_error()); //do the query if($rows = mysql_num_rows($query)){     $_SESSION['password'] = $password; //store the users password in a sesions var     $_SESSION['username'] = $username; //store the username in a session var $page = "index.php"; header('Location: ' . $page); }else {     session_destroy(); } ?>[/code]
  24. The error isnt to do with the session anymore. But to do with the header redirect on line 24. From looking at the sreenie, you have output on line 3 - echo "testl"; Remove that otherwise the header function wont work (on line 24). Pleae read the error message correctly and that you understand it.
  25. Did you restart Apache when you made the changes to the httpd.conf file. Also is Apache starting up with any errors/beeps? Other than that I cannot see why it is doing that.
×
×
  • 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.