EdwinKST Posted March 30, 2009 Share Posted March 30, 2009 hello, i am new to PHP and mySQL and was wondering if i could get any sort of help from someone with php knowledge to teach me how to make my windows read a php code on my localhost laptop. what do i require? what do i do after and such? i have installed php, apache server, SQLyog, and mySQL . some previous help that i got is to put the code into the Apache/htdocs folder. i have done that, and my internet browser (mozzila) is still unable to read my code. for example, i have this as a test to see if it would work: <? phpinfo(); ?> but in my internet browser, all i see is the same written coding as stated above, which means it isnt reading the code? i am in a complete state of no ideas about this problem... so my question is mainly, "How/What to do to make a php code work on a localhost?" by any means necessary with details and other options included.. please help if someone is able to. thank you. Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted March 30, 2009 Share Posted March 30, 2009 How are you invoking the test script. You have to use something like http://localhost/scriptname.php so that PHP is invoked. Plus the file extension should be ".php" Ken Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted March 30, 2009 Share Posted March 30, 2009 And use only full php tags - <?php Quote Link to comment Share on other sites More sharing options...
irkevin Posted March 30, 2009 Share Posted March 30, 2009 PFMaBiSmAd got a good point. short php tags doesn't work quite well if it's not defined in php.ini if im correct and because of this, you'll smash your forehead on your keyboard wondering whats going on! and btw, Wampserver seems to work well. Quote Link to comment Share on other sites More sharing options...
taquitosensei Posted March 30, 2009 Share Posted March 30, 2009 It sounds like apache is not setup to parse php. create testphp.html <?php phpinfo(); ?> see if it will parse that if so then check your httpd configuration for this line AddModule mod_php5.c make sure it's not commented out. Quote Link to comment Share on other sites More sharing options...
EdwinKST Posted April 2, 2009 Author Share Posted April 2, 2009 on an added note, i am using windows vista if that has any relation to any errors that im fustrated at right now. to taqiutosensei : AddModule mod_php.c doesnt seem to be in the apache/httpd.conf file at all. any thoughts about that? or is something terribly wrong? i have tried the code u mentioned under a different file (test2.php) and it still just shows out the written code as it is in my internet browser. pls help. to kenrbnsn : in my internet browser, i type out " http://localhost/test.php ", and i have put the files (in .php) that i needed to read in the apache/htdocs folder. here is one example of a php file im working on, and before u check the code below, id like to mention that this code seems to work on another friends localhost laptop perfectly with just a simple login interface as its output but doesnt on mine: <? session_start(); ob_start(); include("functions/db.php"); $getDB=ob_get_contents(); ob_end_clean; ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <link rel="stylesheet" type="text/css" href="css/general.css" /> <link rel="stylesheet" type="text/css" href="css/forms.css" /> </head> <body> <? if ( (isset($_POST['c_email'])) && (isset($_POST['p_word'])) ) { $sql="select * from c_user where c_email='" . $_POST['c_email'] . "' AND c_pword='" . $_POST['p_word'] . "'"; $result=mysql_query($sql); while ($row=mysql_fetch_array($result)) { $c_type=$row['c_type']; } if (empty($c_type)) { $error="There was an error in your login information. Please try again."; } else if ($c_type=='S') { $_SESSION['c_email']=$_POST['c_email']; $_SESSION['c_pword']=$_POST['p_word']; ob_start(); header('Location: student/main.php'); ob_end_clean; } else if ($c_type=='T') { $_SESSION['c_email']=$_POST['c_email']; $_SESSION['c_pword']=$_POST['p_word']; ob_start(); header('Location: teacher/main.php'); ob_end_clean; } } ?> <div id="wrapper"> <form action="login.php" method="post"> <table class="generic" id="login"> <tr><th colspan='2'><? echo $error; ?></th></tr> <tr><td>E-mail:</td><td><input type='text' name='c_email' id='c_email' class='data_form'></td></tr> <tr><td>Password:</td><td><input type='password' name='p_word' id='p_word' class='data_form'></td></tr> <tr><th colspan='2'><button type="submit">login!</button></th></tr> </table> </form> </div> </body> </html> Quote Link to comment Share on other sites More sharing options...
taquitosensei Posted April 2, 2009 Share Posted April 2, 2009 Here's some good info on getting php and apache running on Vista http://senese.wordpress.com/2007/06/06/install-php-5-under-apache-22-and-windows-vista/ Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.