PHP - Php Error I Just Can't Figure Out, Deals With Classes
Here is the code:
Code: [Select] <?php if (!defined('INCLUDE_GUARD')) { header("Location: /errors/forbidden"); return; } include_once("incs/cls/DatabaseManager.class.php"); include_once("incs/cls/VariantTemplate.class.php"); class Core { private $_logger; private $_self_test_results; private $_config; private $_dbmgr; private $_vtemp; public __construct() // this is line 19 { $this->setupLogger(); $this->_self_test_results = array(); $this->_self_test_results['missing'] = array(); $this->_self_test_results['failed'] = array(); $this->_config = array(); $this->_dbmgr = null; $this->_vtemp = null; $this->selfTest(); } Here is the error I've been receiving. Parse error: syntax error, unexpected T_STRING, expecting T_VARIABLE in /home/ditecha1/public_html/slick/incs/cls/SlickCMSCore.class.php on line 19 I am finding this error extremely weird, my host uses PHP 5.2.14. I was setting the private variables directly (without the assistance of the constructor), but I removed this and had the constructor set basic values to start with to see if this was the issue, but it wasn't. I've tried commenting out the include_once lines, since they are also in development I thought maybe an error was being carried over in to this file as the includes were happening, but still no change in the error message at all. Any help would be greatly appreciated! Similar Tutorials<?php class Post{ private $user_obj; private $con; public function __construct($con, $user){ $this->con = $con; $this->user_obj = new User($con,$user); } public function submitPost($body,$user_to){ $body = strip_tags($body);////Removing HTML TAGS $body = mysqli_real_escape_string($this->con,$body); $check_empty = preg_replace('/\s+/', '', $body);//delte all spaces if($check_empty != ""){ //Current Date and time $date_added = date("Y-m-d H:i:s"); //get username $added_by = $this->user_obj->getUsername(); //if user have not a profile send to the none if($user_to == $added_by){ $user_to = "none"; } ////insert query $query = mysqli_query($this->con,"INSERT INTO posts VALUES('','$body','$added_by','$user_to','$date_added','no','no','0')"); $retured_id = mysqli_insert_id($this->con); //insert notification //Update post count for user $num_post = $this->user_obj->getNumPosts(); $num_post++; $update_query = mysqli_query($this->con,"UPDATE users SET num_post = '$num_post' WHERE username = '$added_by'" ); } public function loadPostsFriends(){ $str = ""; //string to return $data = mysqli_query($this->con,"SELECT * FROM posts where deleted = 'no' ORDER by id DESC"); while($row = mysqli_fetch_array($data)) { $id = $row['id']; $body = $row['body']; $added_by = $row['added_by']; $date_time = $row['date_added']; /// Creating user post on other user profile if($row['user_to'] == "none"){ user_to = ""; else { $user_to_obj = new User($con,$row['user_to']); $user_to_name = $user_to_obj->getFirstandLastname(); $user_to = "to <a href='" . $row['user_to'] . "'>" .$user_to_name . "</a>"; } // check if user account was closed $added_by_obj = new User($this->con,$added_by); if($added_by_obj ->isClosed()){ continue; } $user_details_query = mysqli_query($this->con,"SELECT first_name,last_name,profile_pic FROM users where username = '$added_by'"); $user_row = mysqli_fetch_array($user_details_query); $first_name = $user_row['first_name']; $last_name = $user_row['last_name']; $profile_pic= $user_row['profile_pic']; ///time stamp $date_time_now = date("Y-m-d H:i:s"); $start_date = new Date_Time($date_time);////Time_of_post $end_date = new Date_Time($date_time_now);///Current_time $intervel = $start_date->diff($end_date); if($intervel->y >< 1 ){ if($intervel ==1 ) $time_message = $intervel->y . " year ago";/// 1 Year Ago else $time_message = $intervel->y . " years ago"; //1+ year ago } else if($intervel-> m >= 1 ){ if($intervel->d == 0){ $days = " ago"; } else if($intervel->d == 1){ $days = $intervel->d."day ago"; } else { $days = $intervel->d."day ago"; } if($intervel->m == 1){ $time_message = $intervel->m." month".$days; } else $time_message = $intervel->m." months".$days; } } else if($intervel->d >= 1){ if($intervel->d == 1){ $days = "Yesterday"; } else { $days = $intervel->d."days ago"; } } else if($intervel->h >= 1){ if($intervel->h == 1){ $time_message = $intervel->h." hour ago"; } else { $time_message = $intervel->h." hours ago"; } } else if($intervel->i >= 1){ if($intervel->i == 1){ $time_message = $intervel->i." minute ago"; } else { $time_message = $intervel->i." minutes ago"; } } else{ if($intervel->s < 30){ $time_message = "Just Now"; } else { $time_message = $intervel->s." seconds ago"; } } $str .= "<div class='status_post'> <div calss='post_profile_pic'> <img src='$profile_pic' width='50'> </div> <div calss='posted_by' style='color#ACACAC;'> <a href = '$added_by'> $first_name $last_name </a> $user_to ; ; $time_message </div> <div id = 'post_body'$body<br></div> </div> " } echo $str; } } ?> When i run this code this show me the error Parse error: syntax error, unexpected 'public' (T_PUBLIC) in C:\xampp\htdocs\social\Classes\Post.php on line 39 the line 39 is public function loadPostsFriends() I check the code again and again but i cant find the error please help in this error Hi im still learning php and have been running through the tutorials on making a user authentication system but im getting an error on one line but ive got the same code else where and its fine... Code: [Select] // Must have at least one character if (strspn($_POST['user_name'],$span_str) == 0) { return false; } Im getting the error on the if statment but no matter what i try it still tells me theres an error... Heres the full function code: Code: [Select] function account_namevalid() { // parameter for use with strspan $span_str = "abcdefghijklmnopqrstuvwxyz" . "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-"; // Must have at least one character if (strspn($_POST['user_name'],$span_str) == 0) { return false; } // Must contain all legal characters if (strspn($_POST['user_name'],$span_str) != srnlen($name)) { return false; } // Min and Max length if ($strlen($_POST['user_name']) < 5) { return false; } if strlen($_POST['user_name']) > 25 { return false; } // Illegal names if (eregi("^((root)|(bin)|(deamon)|(adm)|(lp)|(sync)|(shutdown)|(halt)|(mail)|(news)|(uucp)|(operator)|(games)|(mysql)| (httpd)|(nobody)|(dummy)|(www)|(cvs)|(shell)|(ftp)|(irc)|(debian)|(ns)|(download)))$", $_POST['user_name'])) { return false; } if (eregi("^(anoncvs_)", $_POST['user_name'])) { return false; } return true; } Any help or info would be greatfull... Cheers Chris Can someone please give me some guidance on how to deal with the following warning Quote
Warning: move_uploaded_file(../usernet/img/60ff59c9f0a830.45733158.jpg): Failed to open stream: Permission denied in /opt/lampp/htdocs/site/admin/add_post.php on line 23 All directories and files in the path have full owner permissions and I've made myself the owner of them all (I'm on a linux system). I've also done the same with the /tmp folder. I can't even think of anything else to change and haven't found anything online that solves the issue. in case it's needed, the php is as follows: <?php require("assets/initializations.php"); if(isset($_POST['add_post']) && !empty($_FILES['post_image'])) { $filename = $_FILES['post_image']['name']; $file_tmp_name = $_FILES['post_image']['tmp_name']; $filesize = $_FILES['post_image']['size']; $file_ext = explode('.', $filename); $file_act_ext = strtolower(end($file_ext)); $allowed = array('jpeg', 'jpg', 'png', 'gif'); if(!in_array($file_act_ext, $allowed)) { header("Location: add_post.php?message=file_type_not_allowed"); } else { if($filesize > 10000000) { header("Location: add_post.php?message=file_too_large"); } else { $file_new_name = uniqid('', true) . "." . $file_act_ext; $dir = "../usernet/img/"; $target_file = $dir . basename($file_new_name); move_uploaded_file($file_tmp_name, $target_file); echo "<script>alert('Image uploaded successfully');</script>"; } } } I do get the javascript alert that's it's been successfully uploaded, but the image doesn't make it into the specified directory and I get the warnings at the top. I'm also, probably obviously from the path, using XAMPP server for development. TIA Fatal error: Cannot redeclare class MySQLDB in /home/xservers/public_html/skylar/VIP/include/database.php on line 14 I am getting Fatal error: Uncaught Error: Call to a member function real_query() on null with this code: public final function Retrieve($TABLE, $CRIT){ $_query = "SELECT * FROM `{$TABLE}` WHERE "; foreach($CRIT as $_field => $info){ $_query .= " `{$_field}` = `{$info}` &&"; } if($this->LINK->real_query(rtrim($_query, ' &'))){ return $this->LINK->store_result(); } else{ return json_encode(array("Error"=>$this->LINK->errno(), "Description"=>$this->LINK->error())); } } (LINK is my mysql_connect() result.) I have tried everything i can think of, ->query, going to mysqli_query, breaking it sown and using a $result variable, but nothing seems to work... Edited March 29, 2019 by KaraethonOK, im not too crash hot on classes, so hoping someone can help me with this error: Quote Fatal error: Call to a member function add_current_page() on a non-object in /path/to/includes/application_top.php on line 312 This is from an osCommerce application (I know someone will probably tell me to post in 3rd party scripts, but I am more interested in whats generally causing the error). The thing that confuses me is that application_top.php is only 236 lines long. This is the code: <?php $Fname = $_POST["Fname"]; if (!isset($_POST['SUBMIT'])) { // if page is not submitted to itself echo the form ?> <html> <body> <head> <title>Personal INFO</title> </head> <body bgcolor="#008080"> <h1><blink><font color="#FF0000"><strong>Naruto Biography Creation</strong></font></blink></h1> <h3><font size="1" color="#0000FF">Please note, info with a (*) must be filled in!</h> </font> <form method="post" action="<?php echo $PHP_SELF;?>"> <p><font size="2"><b>*First Name:</b></font><input type="text" size="30" maxlength="12" name="Fname"><br /> <br /> <font size="2"><b>*Last Name:</b></font><input type="text" size="30" maxlength="36" name="Lname"><br /> <br /> <b><font size="2">*Gender:</font></b><br /> <input type="radio" value="Male" name="Gender" style="font-weight: 700"><b><font size="2">Male</font> </b><input type="radio" value="Female" name="Gender" style="font-weight: 700"><b><font size="2">Female</font></b></p> <p><b><font size="2">Background Info:</font></p> <textarea rows="3" cols="33" name="Background INFO" wrap="hard">Enter your Character's History</textarea><p><font size="2">Appearance:</font></p> <p> <textarea rows="3" cols="33" name="*Appearance" wrap="hard">State how your character look</textarea></p> <p><font size="2">Personality:</font><br/><span> <textarea rows="3" cols="33" name="*Personality" wrap="hard">Explain your Character's qualities, attitude, etc.</textarea></span></p> <p><span><br /></span> <font size="2">*Affiliation:</font><br /> <select name="Affiliation" size="3" width="8"> <option value="None" selected>Select one</option> <option value="Leaf">Leaf</option> <option value="Sand">Sand</option> <option value="Cloud">Cloud</option> <option value="Rogue">Rogue</option> </select><br /> <font size="2">*Rank:</font><br /> <select name="Rank" size="3" width="8"> <option value="none" selected>Select one</option> <option value="Gennin">Genin</option> <option value="Chuunin">Chuunin</option> <option value="Jounin">Jounin</option> <option value="S class">S class</option> </select> </p> <p> <input type="submit" value="submit" name="submit"></p> </form> </body> </html> <? } esle { echo "Hello,".$Fname." ".Lname.".<br />"; } ?> I get this all the time Quote Parse error: syntax error, unexpected $end in F:\wamp\www\index.php on line 78 I work on Wamp, and I am a beginner so I am totally lost could anyone help please I hate header errors... I can never figure them out, im getting this error; Warning: Cannot modify header information - headers already sent by (output started at /home/damnpeti/public_html/restrict2.php:6) in /home/damnpeti/public_html/restrict2.php on line 62 Code: <?php $testDB = mysql_connect('localhost', $db_user, $db_pwd); mysql_select_db ($db_name); if (!$testDB) { die('Could not connect: ' . mysql_error()); } $surfer_ip = $_SERVER["REMOTE_ADDR"]; $str_sql = "select * from ".$db_table." where ipaddress='".$surfer_ip."'"; $result = mysql_query($str_sql); if ($row = mysql_fetch_assoc($result)) { $blocked_time = strtotime($row['blocked_time']); if($blocked_time != 0) { $current_time = time(); if($current_time - $blocked_time > 3600*24) //24 hours past { $str_sql = "delete from ".$db_table." where ipaddress='".$surfer_ip."'"; mysql_query($str_sql); $str_sql = "insert into ".$db_table." (ipaddress, surf_index) values('".$surfer_ip."', 1)"; mysql_query($str_sql); } else { die ("<center><div class='errors'>You have accessed this page too many times. To regain access, purchase a license or wait 24 hours.</div></center>"); } } else { if($row['surf_index'] < 2) { $str_sql = "update ".$db_table." set surf_index=surf_index+1 where ipaddress='".$surfer_ip."'"; mysql_query($str_sql); } else { $str_sql = "update ".$db_table." set blocked_time='".date ("Y-m-d H:i:s")."' where ipaddress='".$surfer_ip."'"; mysql_query($str_sql); die ("<center><div class='errors'>You have accessed this page too many times. To regain access, purchase a license or wait 24 hours.</div></center>"); } } } else { $str_sql = "insert into ".$db_table." (ipaddress, surf_index) values('".$surfer_ip."', 1)"; mysql_query($str_sql); } if(!isset($_COOKIE['surf_no'])) setCookie('surf_no', '1'); else setCookie('surf_no', $_COOKIE['surf_no']+1); if ($_COOKIE['surf_no'] > 2) die("<center><div class='errors'>You have accessed this page too many times. To regain access, purchase a license or wait 24 hours.</div></center>"); include 'http://damnitpetitions.com/cut/index3.php'; ?> Line 62 is if ($_COOKIE['surf_no'] > 2) I know it has something to do with the cookie... but Idk? I need the include there. If there include isnt where its at, the script is worthless. Hello again! I've been trying out new things (well, new for me) in php again. This time I decided to try a real challenge and make a forum system. A friend suggested I use a class for all database functionalities. i was reluctant at first, but decided if I was going to try using classes for the first time, it might as well be with this. With some guiding help, I set up the files and gave it a visual once over to check for errors. Nothing seemed out of place, but when I loaded the page to try it out, I got this error: Quote Fatal error: Call to a member function query() on a non-object in /home/ck9/public_html/planning/forumbuild/list.php on line 20 I didn't see anything out of line, so I consulted my friend about it. He made a few small adjustment suggestions, but nothing fixed the issue. I then bugged my host about it, and he couldn't find anything wrong either. Both people are highly experienced in php, so when they say it SHOULD be working I am left rather confused. Here is list.php: Code: [Select] <?php include("db.class.php"); include("db.config.php"); $db = new databaseConnection($config['user'],$config['pass'],$config['database']); $g = $_GET['g']; $s = $_GET['s']; $t = $_GET['t']; function tablestart($a = '1') { global $db; echo "<table border='" . $a . "' cellpadding='10' cellspacing='0' align='center' width='80%' style='color: #C0C0C0'>\n"; } function contents($table, $a, $b = '1', $c = '1') { global $db; $db->query("SELECT * FROM $table"); while($row = $db->fetch_array()) { if($row['level'] <= $_SESSION['ulevel']) { echo "<tr><td width='5%'><!--indicator--></td><td width='80%'><a href='index.php?pg=h&g='" . $row['g']; if(($a > '1') && ($row['g'] == $b)) { echo "&s=" . $row['s']; if(($a > '2') && ($row['s'] == $c)) { echo "&t=" . $row['t']; } } } echo "' style='color: #C0C0C0 ; text-decoration: none'><font size='4'>" . $row['name'] . "</font><br /><fpnt size='3'>" . $row['desc'] . "</td><td width='15%'><!--last update--></td></tr>\n"; } } if(empty($_SESSION['ulevel'])) { $_SESSION['ulevel'] = '0'; echo "<font color='#CC0000'><center>You need to register to post in these forums.</center></font><br />\n"; } if(empty($g)) { tablestart(); contents('group', '1'); echo "</table>\n"; } elseif(empty($s)) { tablestart(); contents('section', '2', $g); echo "</table>\n"; } elseif(empty($t)) { tablestart('0'); echo "<tr><td width='80%'></td><td><!--new topic--></td></tr>\n</table>\n"; tablestart(); contents('topic', '3', $g, $s); echo "</table>\n"; } elseif(!empty($t)) { tablestart('0'); echo "<tr><td width='80%'></td><td><!--new topic and reply--></td></tr>\n</table>\n"; $data = file_get_contents('topics/g' . $g . 's' . $s . 't' . $t . '.txt'); $post = explode("<!--p-->", $data); $length = count($post); tablestart('1'); for($z = '0'; $z < $length; $z ++) { $i = '0'; $cont = explode("<!--e-->", $post[$pos]); echo "<tr><td><b>" . $cont[$i] . "</b><br /><!--future additions--></td><td>\n<table width='100%' style='font-size: xx-small'>\n<tr><td height='3' width='75%'>"; $i ++; echo "Posted on" . $cont[$i] . "</td><td height='3' width='25%'><!--future additions--></td></tr><tr><td width='100%'>"; $i ++; echo $cont[$i] . "</td></tr></table></td></tr>\n"; } echo "</table>\n"; } ?> My aim here was to have a single page to display the groups, sections, topics, and posts in order to keep database calls where I could find them easily. and here is the class file: Code: [Select] <?php class databaseConnection { protected $link; protected $lastResult; function databaseConnection($user,$pass,$database) { $this->link = mysql_connect("localhost",$user,$pass); if( !$this->link ) { die('Vital information missing.'); } else { mysql_select_db($database,$this->link) or die('could not find database: ' . mysql_error()); } } function query($query) { $this->lastresult = mysql_query($query) or die('MySQL error: ' . mysql_error()); return $this->lastresult; } function fetch_array($result = false) { if(!$result) { return mysql_fetch_array($this->lastresult); } else { return mysql_fetch_array($result); } } } ?> I have tried everything from adjusting the php tags to putting the class directly in the page. The config file just provides the user, pass, and which database to connect to. I've checked it's formatting a few times just in case. I've been spending long hours learning about classes and their magic methods. I just came across a tutorial which showed a constructor like this:
class Device { //... public function __construct(Battery $battery, $name) { // $battery can only be a valid Battery object $this->battery = $battery; $this->name = $name; // connect to the network $this->connect(); } //... }the Battery part instantly caught my attention. Here had previously made a Battery class (and a more complete Device class) but the next thing he did really caught my interest: $device = new Device(new Battery(), 'iMagic'); // iMagic connected echo $device->name; // iMagicwhat the hell is going on here? Is this another way to include the methods and properties of one class into another class, in order words is this the same thing as: class Device extends BatteryI don't think so because this new Battery() thing looks more like its creating an object inside the Device object. Previously the only way I could to that was to type $battery = new Battery() inside one of my methods. But this looks like hes doing something different. Can anyone explain whats going on here? The whole tutorial is he http://code.tutsplus...-php--net-13085 in the main Device method he has a premade $battery variable to hold the Battery object. Sometimes I have multiple classes containing functions which I'd like to include in my main class. I can only extend one class, so I usually extent a class containing only properties, no methods. I still don't know what difference making that info class abstract is, I'd appreciate if anyone could tell me. Also I'd love to know what the point in static methods is. I've never used them because I've never seen the point. Is it just to make it easier to call the methods because you don't need to create an object instance to call them? Sorry for the extra questions, the first one is what I'm really wondering about. Not sure how to describe what I'm trying to do here in the title, but here goes with what I am trying to accomplish. I've got a few hundred lines of code in total so far, so I'll try to keep it as short as I can. I've got an application that I am programming using classes for each module and right now I am coding the base classes that I need in order for it to run (database, errors, logging, etc). What I'm doing for my database class is I have a query factory and it extends the MySQLi class so I can process, clean and code the rest of my app faster. I also have another, unrelated class "Error", which will be used for processing errors I might come across. I'd rather do it this way instead of having to call trigger_error and error_log every time there is an error. I'd also not like to have to call a new instance of an object every time I need to use something from that class. Is there any way I can call a class within a class and return it as an object for all the methods within the class? I've tried the methods below, but no luck I've tried others, but I'm trying to keep it brief and get what I'm trying to do across. <?php class QueryFactory extends MySQLi { public $err = new error(); //Doesn't work. public $err = error(); //Nope. #This is the function that I need the $err object for. function set($fields, $newvals) { if ( is_array($fields) && is_array($newvals) ) { if ( count($fields) != count($newvals) ) { //Instead of below, I want to do something like $err->('Array lengths must match for method', 256, $islogged = 1); trigger_error('Array lengths must match for method', 256); } } } } The thing is, I have a "run.inc.php" which does include and create new objects for running just the basic app and if I try to redeclare the error class in query.class.php, it gives me an error saying I can't do that, but if i try to call $err from the page that has all the classes defined it throws an error saying that my method is undeclared. I'd like my error class be available to every other class I create so I can display and log errors as needed. Any suggestions or links to point me where I'd like to go? hey all; i created a script that just allows a user to record an IP address and it presents them in a table.. issue: each record draws its own row and a colum for an image (for deleting).. I can't igure out how I can delete the one row when they click on image(little x) to delete... issue2: it's showing the error message when you bring up the screen telling them they didn't enter anything even prior to them hitting submit... issue3: it's allowing me to enter the same IP again code: <?php session_start(); if (!isset($_SESSION['username'])) { echo "Sorry you must be logged in to view this page<BR>"; echo "Please <a href='index.php'>GO BACK</a> and try again"; exit(); } else { if ($_SESSION['username']) { $username = $_SESSION['username']; $userid = $_SESSION['userid']; } } //script v1.0 ipdatabase.php - create a list of IP addresses that the user has added to their list to remember. can add or remove IPs ?> <style type="text/css"> <!-- .style1 {color: #FFFFFF} --> </style> <table align="center" width="550" border="0" cellpadding="0" cellspacing="0" bgcolor="#000000"> <!--DWLayoutTable--> <tr> <td height="106" colspan="3" valign="top"><img src="images/myvpc.png" width="550" height="106"></td> </tr> <tr> <td width="16" height="57"> </td> <td width="516" valign="top"><div align="center" class="style1"> <p>IP DATABASE</p> <p align="left">add or remove IP address you have encountered in the game thus far for later use!</p> </div></td> <td width="18"> </td> </tr> <tr> <td height="100"> </td> <td valign="top"> <form action="ipaddressadd.php" method="POST"> <p> </p> <p><span class="style1">IP ADDRESS</span>: <input type="text" name="ipaddress" size="16"> <input type="submit" name="submit" value="submit"> </p> </form></td> <td> </td> </tr> <tr> <td height="17"></td> <td valign="top"><img src="images/filler.jpg" width="516" height="19"></td> <td></td> </tr> <tr> <td height="296"></td> <td valign="top"> <?php $submit = $_POST['submit']; if ($submit) { $ipaddress = ip2long($_POST['ipaddress']); } //script to add IP to database include('connectdb.php'); mysql_select_db('heaven_users') or die (mysql_error()); if (isset($ipaddress,$submit)) { mysql_query("INSERT INTO ipdatabase (userid,ipaddress) VALUE ('$userid','$ipaddress')") or die ("Could Not write to database, Please try again"); } else echo "<center><font color='#ff0000'>You didn't add anything mate!</font></center>"; echo "<br />"; echo "<table align='center' border='1'><tr align='center'><th><font color='#ffffff'>SAVED IPADDRESS</font></th></tr><tr>"; $query = mysql_query("SELECT * FROM ipdatabase WHERE userid = '$userid'"); while ($result = mysql_fetch_assoc($query)) { $ip = long2ip($result['ipaddress']); echo "<tr align=\"center\"><td><font color='#ffffff'>".$ip."</font></td><td><a href='deleteip.php'><img border='0' src='images/delete.png'></a></td></tr>"; } echo "</table>"; ?> </td> <td></td> </tr> </table> Hi, good pm masters! So i have this code Code: [Select] <td><img src="images/layout/<?php echo base64_decode($_GET['layout']); ?>" width="50%" height="50%" /></td> $_GET['layout'] is encoded that's y i have a decode there, the image name will then be combined to the src like this -> image/layout/1.jpg.. when i view the source the src is correct but it doest show the image.. cant seem to find whats wrong.. my folder structure is sandbox>images>layout>file.jpg the php file (where the code above is) inside the sandbox. sorry if am i missing something sooo eaasy.. i was doin alot of coding this morning until now so i don't know what to think anymore.. guys is it possible to somehow compare something like these two together and make a choice depending on the out come SystemKeyv1.0 and PasswordCrackerv2.0 PasswordCrackerv2.0 is grater than SystemKeyv1.0 can these be compared somehow? thank for advise guys; Cheers i was wondering how i would go about making a single page that would have sections on it and if you click a section the page reloads and shows the information that is within that section? i got my code to show both the section and its information at the same time but cannot figure out how to do the above. please help. thank you -Adam The page that I'm working on is a quiz results page. In this section of code I am simply printing the question, then each answer choice is printed depending on a few if statements. Let's say the answer choice in this first statement was "Baseball." The four possibilities depending on the student answer I want a Baseball - You Got This Right or Baseball - Correct Answer or Baseball - Your Answer or Baseball So if the student gets a question wrong one choice should say "Correct Answer" next to it and one other would have "Your Answer" next to it. Pretty simple and straightforward. I can get the correct results from everything but the second ifelse statement (Baseball - Your Answer). No matter what i do I can't get this to work. Here is the code below and some clarifications: $StudAns = Student's answer $Choices = The particular answer choice being evaluated $CorrectAnswer = obvious Code: [Select] $StudAns = array($QChoices['Q1Choice'], $QChoices['Q2Choice'], $QChoices['Q3Choice']); $ContentsQuery = mysql_query("SELECT Question, Choice1, Choice2, Choice3, Correct_Answer FROM Module_1_Quiz") or die(mysql_error()); while ($Contents = mysql_fetch_array($ContentsQuery)) { $i =0; $Choices = array($Contents['Choice1'], $Contents['Choice2'], $Contents['Choice3']); $CorrectAnswer = $Contents['Correct_Answer']; echo "<span id='answers'><table width = '600' border='0' align='center' id='answers' bgcolor='#FFFFCC'><tr><td>"; echo $Contents['Question']; echo "</td></tr>"; echo "<tr><td><ol type = 'a'><li>"; // Checks what should be printed for the first answer option if ($Choices[$i] == $CorrectAnswer && $StudAns[$i] == $CorrectAnswer) { echo $Choices[$i]; echo " - You Got This Right!"; } elseif ($Choices[$i] == $CorrectAnswer && $StudAns[$i] != $CorrectAnswer) { echo $Choices[$i]; echo " - Correct Answer"; } elseif ($StudAns[$i] != $CorrectAnswer && $CorrectAnswer[$i] != $Choices[$i]) { echo $Choices[$i]; echo " - Your answer"; } else { echo $Choices[$i]; } echo "</li><li>"; $i++; // Checks what should be printed for the second answer option if ($Choices[$i] == $CorrectAnswer && $StudAns[$i] == $CorrectAnswer) { echo $Choices[$i]; echo " - You Got This Right!"; } elseif ($Choices[$i] == $CorrectAnswer && $StudAns[$i] != $CorrectAnswer) { echo $Choices[$i]; echo " - Correct Answer"; } elseif ($StudAns[$i] != $CorrectAnswer && $CorrectAnswer[$i] != $Choices[$i]) { echo $Choices[$i]; echo " - Your answer"; } else { echo $Choices[$i]; } echo "</li><li>"; $i++; // Checks what should be printed for the third answer option if ($Choices[$i] == $CorrectAnswer && $StudAns[$i] == $CorrectAnswer) { echo $Choices[$i]; echo " - You Got This Right!"; } elseif ($Choices[$i] == $CorrectAnswer && $StudAns[$i] != $CorrectAnswer) { echo $Choices[$i]; echo " - Correct Answer"; } elseif ($StudAns[$i] != $CorrectAnswer && $CorrectAnswer[$i] != $Choices[$i]) { echo $Choices[$i]; echo " - Your answer"; } else { echo $Choices[$i]; } echo "</li></ol></table></span>"; } Thanks everyone! I'm terrible at designing websites (that's pretty much out of the question), but I would like to work on my php skills. I just can't figure out anything I can write that isn't extremely hard.. ideas? I am trying to redirect users depending on their coupon code input I am using the following script in the form created in dreamweaver: Code: [Select] <form action="CodeUserredirect.php" method="post" enctype="multipart/form-data" name="" id=""> <input type="hidden" name="redirect" value="CodeUserredirect.php" /> <p class="style4">Redeem your Gift Certificate Savings for Special Orders he </p> <p><span class="style78">Enter Coupon code</span> <input name="CouponCode" type="text" id="CouponCode" size="9"> <input type="submit" name="CheckCode" id="CheckCode" value="Check Code"> <br/> <br/> </p> </form> and I am using the following code in my php file: <?php$coupon_code = $_POST['couponcodenumber'];if ($coupon_code = $some_other_value) { $redirected_address = 'Location: specialordersDiscountForm.php'; header ($redirected_address); exit();} else { $redirected_address = 'Location: specialorderwrongcode.php'; header ($redirected_address); exit();}?> () Not sure where the issue is in these coding but it is not working to redirect users depending on their coupon input as intended. Can anyone supply me with a working code or explain what the issue is? thanks! i have an array called $imageArray like this Array ( [0] => 'Dashka'_Darren_Sheehan_1.jpg [1] => 'Dashka'_Darren_Sheehan_10.jpg [2] => 'Dashka'_Darren_Sheehan_2.jpg [3] => 'Dashka'_Darren_Sheehan_3.jpg [4] => 'Dashka'_Darren_Sheehan_4.jpg [5] => 'Dashka'_Darren_Sheehan_5.jpg [6] => 'Dashka'_Darren_Sheehan_6.jpg [7] => 'Dashka'_Darren_Sheehan_7.jpg [8] => 'Dashka'_Darren_Sheehan_8.jpg [9] => 'Dashka'_Darren_Sheehan_9.jpg [10] => . [11] => .. [12] => Aaron_Kidney_1.jpg [13] => Aaron_Kidney_10.jpg [14] => Aaron_Kidney_11.jpg [15] => Aaron_Kidney_12.jpg [16] => Aaron_Kidney_13.jpg [17] => Aaron_Kidney_14.jpg [18] => Aaron_Kidney_15.jpg [19] => Aaron_Kidney_16.jpg [20] => Aaron_Kidney_17.jpg [21] => Aaron_Kidney_18.jpg and i also have another array called $_names Array ( [0] => 'Dashka'_Darren_Sheehan [1] => Beefit_Gyms [2] => Aaron_Kidney [3] => Dean_Mitchell [4] => Colin_O_Neill [5] => Keith_McManus ) if a name in array $_names exists in the $imageArray i want to insert the images for that person into one column of a table like this <tr> <?php foreach ($names as $name): ?><th><?php htmlout($name); ?></th><?php endforeach; ?> </tr> <tr> <td><img src="../images/'Dashka'_Darren_Sheehan_1.jpg" width="204"/></td> <td><img src="../images/Aaron_Kidney_1.jpg" width="204"/></td> <td>row 1, cell 1</td> <td>row 1, cell 2</td> <td>row 1, cell 1</td> <td>row 1, cell 2</td> </tr> <tr> <td><img src="../images/'Dashka'_Darren_Sheehan_2.jpg" width="204"/></td> <td><img src="../images/Aaron_Kidney_2.jpg" width="204"/></td> <td>row 1, cell 1</td> <td>row 1, cell 2</td> <td>row 1, cell 1</td> <td>row 1, cell 2</td> </tr> can anyone help me write the logic for this?? I cant figure it out... hello all, i can't get this to work; i'm able to echo both accts entered into the form via the _get but can't pull both balances using the $from_acct and $to_acct only the first query working do I have it formated wrong <?php //check for submit $submit = $_GET['submit']; //end looking for submit //set varibles if submit is present if (!$submit) { echo "Sorry Mate I don't see you have submitted anything for me to process"; } else { //make the connecting and set some varibles from _get $from_acct = $_GET['from_acct']; $to_acct = $_GET['to_acct']; $amount = $_GET['amount']; $connect = mysql_connect("localhost","root","") or die (mysql_error()); mysql_select_db('users') or die ("no such database exisit"); $query = mysql_query("SELECT * from members WHERE bankaccount=$from_acct") or die ("Could not locate to account"); $query2 = mysql_query("SELECT * from members WHERE bankaccount=$to_acct") or die ("Could not locate to account"); while ($result = mysql_fetch_assoc($query) && $result2 = mysql_fetch_assoc($query2)) { $fromb = $result['balance']; $tob = $result2['balance']; } //make a check to see if the account that is sending has the money to send if ($fromb<$amount) { echo "Mate you don't have enough cash to transfer " .$amount. "to this account<br />"; echo "Your Current Balance available for transfer is " .$fromb; } else { $newbalancefrom = $fromb - $amount; $newbalanceto = $tob + $amount; //make the transfer $transfer = mysql_query("UPDATE 'users' . 'members' SET 'balance' = '$newblanceto' WHERE bankaccount='$to_acct'") or die ("could not write to profile"); $transfer2 = mysql_query("UPDATE 'users' . 'members' SET 'balance' = '$newblancefrom' WHERE bankaccount='$from_acct'") or die ("Could Not Write to From Account"); if ($transfer) { echo "Transfer Complete Thanks!"; } else { echo "There was a error in the transfer process please try again"; } } } echo $fromb . "<br />"; echo $tob . "<br />"; echo $from_acct . "<br />"; echo $to_acct . "<br />"; ?> <h2>Peer to Peer Transfer</h2><br><br> <form action="testtrans.php" method="get"> Amount to Transfer: <input type="text" size="8" name="amount"><br> From Account: <input type="text" size="15" name="from_acct"> To Account: <input type="text" size="15" name="to_acct" /><br /> <input type="submit" name="submit" value="transfer" /> </form> |