Jump to content

anotherphpnoob

New Members
  • Posts

    9
  • Joined

  • Last visited

    Never

Everything posted by anotherphpnoob

  1. error_reporting was set to E_ALL however display_errors was not set to ON. both of these are now set to the following. display_errors = ON error_reporting = E_ALL ran through the scripts as usual, not sure what im looking for, or what should or should not be happening.
  2. the SQL query is fine. i built the page to show me that it was working. I then commented out all the stuff because i didnt want it to show up and built the rest of the stuff so that when it does work it, $_SESSION gets its variables and then goes to index.php. this code is one </table> short but if you look in the code i posted before its there. // echo "<table>\n"; //echo "<tr>\n"; foreach ($row as $val) { $_SESSION[$rowcount] = $val; //echo "<td>$val</td>\n"; $rowcount=$rowcount+1; $count=$count+1; } //echo "</tr>\n"; } I also tested whether or not $_SESSION was even getting anything from that statement later on in the page, and then proceeded to comment that out as well. //echo '</table>'; //echo "Session row 1 = ".$_SESSION[0]."<br />"; //echo "Session row 2 = ".$_SESSION[1]."<br />"; //echo "Session row 3 = ".$_SESSION[2]."<br />"; //echo "Session row 4 = ".$_SESSION[3];
  3. script.php <?php session_start(); //database server define('db_server', 'localhost'); //user, password, and database variables $db_user = 'user'; $db_password = 'password'; $db_dbname = 'people'; /** * Run MySQL query and output * results in a HTML Table */ function outputQueryResults() { $username=$_POST['name']; $password=$_POST['pass']; $count=0; $rowcount=0; //run a select query $select_query = "SELECT * FROM names WHERE username= '".$username."' AND password = '".$password."'"; $result = mysql_query($select_query); //output data in a table while ($row = mysql_fetch_row($result)) { // echo "<table>\n"; //echo "<tr>\n"; foreach ($row as $val) { $_SESSION[$rowcount] = $val; //echo "<td>$val</td>\n"; $rowcount=$rowcount+1; $count=$count+1; } //echo "</tr>\n"; } if(is_null($row)||empty($row)&& $count==0) { if (!empty($_SERVER['HTTPS']) && ('on' == $_SERVER['HTTPS'])) { $uri = 'https://'; } else { $uri = 'http://'; } $uri .= $_SERVER['HTTP_HOST']; header('Location: '.$uri.'/error.html'); }else{ //echo '</table>'; //echo "Session row 1 = ".$_SESSION[0]."<br />"; //echo "Session row 2 = ".$_SESSION[1]."<br />"; //echo "Session row 3 = ".$_SESSION[2]."<br />"; //echo "Session row 4 = ".$_SESSION[3]; if (!empty($_SERVER['HTTPS']) && ('on' == $_SERVER['HTTPS'])) { $uri = 'https://'; } else { $uri = 'http://'; } $uri .= $_SERVER['HTTP_HOST']; header('Location: '.$uri.'/index.php'); } } //connect to the database server $db = mysql_connect(db_server, $db_user, $db_password); if (!$db) { die('Could Not Connect: ' . mysql_error()); } else { echo "Connected Successfully...\n"; } //select database name mysql_select_db($db_dbname); //run query and output results outputQueryResults(); //close database connection mysql_close($db) ?> index.php <?php session_start(); if(!isset($_SESSION[1])){ echo "help1";}else{$var=$_SESSION[1]; } echo $_SESSION[1]; echo $var; ?>
  4. I'm taking information from a database and i want to bring it to a new page where i can access it. The database connection, settings and what not are fine.
  5. As the title says session, post and get are not working. This is what i use to initialize them. For get just switch session with get. foreach ($row as $val) { $_SESSION[$rowcount] = $val; // echo "<td>$val</td>\n"; $rowcount=$rowcount+1; } when i was using session i would check to make sure that they were working with a couple of these lines in the same php document. echo "Session row 1 = ".$_SESSION[0]."<br />"; echo "Session row 2 = ".$_SESSION[1]."<br />"; then on the next page where I was trying to receive the variables i was using this just to start off with and make sure i was getting the variables. session_start(); if(!isset($_SESSION[1])){ echo "help1";}else{$var=$_SESSION[1]; } echo $_SESSION[1]; echo $var; if i switch to post and get i get the same results. if there is an easier way to pass variables between pages id love to hear them
  6. Its a login script i execute from an html form like so : <form action="script.php" awesome, exactly what i needed to know and how to do it. I think like three people posted something along these lines thanks for the help everyone.
  7. I am the admin, this is for a school project and basically I just have to make it look pretty.
  8. yes im using apache, and when i execute script.php everything happens exactly as it is supposed to. When i try and view script.php it executes the code. I doubt i have the apache server set up right thought. Any links / websites i should be checking out? Also i tried <?php .... ?> in other parts of my web page and it didn't work, so i don't think it is necessarily because im working with title tags. I hope that i dont have to rename the file .php cause rewriting that page to write everything with php doesn't sound fun.
  9. I am trying to use some php code inside of an html document and it does not work. I have a script.php file that executes perfectly when I try and use it. Here is the code I am currently using: <?php echo "<title>"; echo "the Homepage!"; echo "</title>"; ?> Any suggestions would be great.
×
×
  • 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.