PHP - Function Giving Me Trouble
What I can Do:
Code: [Select] function createDir($path = '/path/to/root/') What I Need To Do: Something like this Code: [Select] $server_root = $_SERVER['DOCUMENT_ROOT']; function createDir($path = $server_root) Or This Code: [Select] function createDir($path = $_SERVER['DOCUMENT_ROOT']) Similar Tutorials(php is a weakness)
Here is the HTML portion for the form:
<form action="send_form_email.php" id="contacts-form" method="post"> I can't figure out how I'm messing up so badly. Anyway, I have:
$con=mysqli_connect("removedforsecurity"); $finderCleanup = mysqli_query($con, "SELECT * FROM Entries ORDER BY PID DESC LIMIT 1"); $finderCleanupArray = mysqli_fetch_array($finderCleanup); $integerCleanup = $finderCleanupArray['PID'] - 40; $lastPID = $finderCleanupArray['PID']; $lastPIDreduced = $finderCleanupArray['PID'] - 8;When I var_dump $lastPID, it returns INT with a number (it works correctly.) Then, I have this: function getResults($con,$lastPIDreduced)$con works correctly in the function, but $lastPIDreduced is "undefined." What is my sin? Thanks. I wrote a simple sales tax function but it keeps come back with a sales tax of 0 the price is coming from a database. Code: [Select] function TotalSalesTax($price) { $salesTax = .07; $TotalSalesTax = $price * $salesTax; number_format($TotalSalesTax, 2); return $TotalSalesTax; } Code: [Select] <tr> <td></td> <td>Sales Tax: </td> <td><?php echo TotalSalesTax($price);?> </td> </tr> product page that the price comes from Code: [Select] <?php session_start(); if(!isset($_SESSION['quantity'])) { $_SESSION['quanity']=array(); //if there are no quantities selected, the array is empty if(is_array($_POST['quantity']))//if there are items in the cart { echo $quantity; header("location: checkOut.php"); } } require_once("functions.php"); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <style type="text/css"> td { border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #30C; border-right-color: #30C; border-bottom-color: #30C; border-left-color: #30C; } #productCatalog { width:400px; margin-right: auto; margin-left: auto; } </style> <link href="doggyTreats.css" rel="stylesheet" type="text/css" /> </head> <body> <?php logo(); navBar(); echo "<div id=\"productCatalog\">"; echo "<form action=\"checkOut.php\" method=\"post\" name=\"catalog\">"; DatabaseConnection(); $query = "SELECT * FROM treats"; $result_set = mysql_query($query) or die(mysql_error()); $i = 0; echo "<table>"; while ($row = mysql_fetch_array($result_set)) { echo"<tr><td width=\"2s00px\"><img src=\"{$row['product_pic']}\" /></td><td width=\"200px\">{$row['product_title']}.<br /><br />{$row['product_Description']}.<br /> Price: \${$row['price']}.<br /><br />Quantity <input name=\"quantity\" type=\"text\" size=\"2\" /></td></tr>"; } echo "<tr>"; echo "<td><input name=\"submit\" type=\"submit\" value=\"Proceed to Checkout\" />"; echo "</table>"; echo "</form>"; echo "</div>"; footer(); ?> </body> </html> hello. i have two functions that are not working because i cant seem to input the php and java correctly.. could someone help please. how do i put these lines into a function: 1 - Code: [Select] function applyBox() { echo ' <div id="apply"> <h3><b><span class="arial18_GRN">Apply NOW</span> to become a<br>BusinessMobiles.com Affiliate</b></h3> <p class="applyText">Drive quality traffic to one of our<br>partners and get paid for it.</p> <a href="#" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Apply','','image/callsToAction/applyButton2.jpg',1)"> <img src="image/callsToAction/applyButton1.jpg" class="applyButton" alt="Apply" name="Apply" width="137" height="36" border="0"></a> </div> '; } this part is not working: onMouseOver="MM_swapImage('Apply','','image/callsToAction/applyButton2.jpg',1)"> i can see that the ' is breaking it. i tried putting .'s but it didn't work : onMouseOver="MM_swapImage('.Apply.','..','.image/callsToAction/applyButton2.jpg.',1)"> 2 - this form: Code: [Select] <div class="form"> <form name="Form" method="post" action="<?PHP echo $_SERVER['PHP_SELF']; ?>"> <input name="submit" type="hidden" value="submit" /></input> <input type="text" class="inputField" name="Uname" id="Uname" value="'.$Uname.'" onfocus="clearUname()"></input> <input type="text" class="inputField" name="PW" id="PW" value="'.$PW.'" onfocus="clearPW()"></input> <input type="image" class="submit" src="image/wrapper/submit.jpg" value="Submit" alt="login" width="36" height="20" border="0" /></input> </form> this part is not working : <form name="Form" method="post" action="<?PHP echo $_SERVER['PHP_SELF']; ?>"> i tried: <form name="Form" method="post" action="'.echo $_SERVER['PHP_SELF'].'"> but no luck. any suggestions ???? thanks ricky hi guys i am including a function in my main script, and i'm calling it aftwerwards. except i cannot echo successfully the data in the $result variable, why? function echoResult(){ $result = 'dan'; return $result; } // 1 echo echoResult(); // don't work. i get empty data. // 2 $fnResult = echoResult(); echo $fnResult; // don't work. get empty data. i have ran get_included_files and the include is being made successfully. i read on php.net and these are the examples they use (user comments!) how do i get the data out of the function and echo it, using this way? okay.. so I found a list of bad words on line that I want to work into my website's insert. I took the time to create a long comma-delimited list and I'm trying to use this in my page but I keep getting errors. I'm not sure what I'm supposed to be escaping because of the many numerous characters in this list. Might someone help? As I didn't want to post a bunch of foul words on this forum, I posted it he http://snipt.org/xmpgk You might not want to visit if you don't like bad words. As the list currently is, I'm getting this error: Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ')' in /home/jeffro/public_html/all/xyzman/inserttodb.php on line 114 ....right on the line where $newwords begins. Hello Everyone, I am working on a project where I have to go in and grab the names of the fields in a table. I got it to work and for it to show me the field names but it also displays a lot more than what I would like for it to do. I keep getting the following error. It is repeated over my screen like 15 times. Quote Warning: mysql_field_name() [function.mysql-field-name]: Field 5 is invalid for MySQL result index 7 in C:\xampp\htdocs\CMS\admin\includes\get_table.php on line 44 This is the section of code that it is referring to. Line 44 is Quote $tablecolumn .= "<p>" . mysql_field_name($fieldnamesquery_result, $table_field) . "<input type='text' name='" . mysql_field_name($fieldnamesquery_result, $table_field) . "' id='" . mysql_field_name($fieldnamesquery_result, $table_field) . "'/>"; Code: [Select] $tablecolumn = "<form name='insert_table' id='insert_table' action='get_database.php' method='post' > <fieldset> <legend>table information</legend>"; for ($table_field = 2; $table_field < $fieldnamesquery_result; $table_field++) { $tablecolumn .= "<p>" . mysql_field_name($fieldnamesquery_result, $table_field) . "<input type='text' name='" . mysql_field_name($fieldnamesquery_result, $table_field) . "' id='" . mysql_field_name($fieldnamesquery_result, $table_field) . "'/>"; <-----This is line 44 } $tablecolumn .= " <p> <input type='submit' name='submit_info' id='submit_info' /> </p> </fieldset> </form> "; echo $tablecolumn; Hello everyone. I am wondering how can i give different id's to a html form? Code: [Select] <?php ... if ($numrows!=0) { // fetching data from the database to variable while ($row = mysql_fetch_assoc($query)) { $view_jam = $row['jamname']; $view_recipe = $row['jamrecipe']; $view_rating = $row['jamrate']; $view_owner = $row['owner']; $view_comments = $row['comments']; $view_count = $row['count']; $view_id = $row['id']; $view_count2 = $row['count2']; echo "Jam name: <b>" . $view_jam . "</b><br />"; echo "Jam recipe: " . $view_recipe . "<br />"; echo "Owner: " . $view_owner . "<br />"; echo "Comments: " . $view_comments . "<br />"; echo "Jam Rating: " . $view_rating . "<br />"; [b]echo '<form action="main.php?id=jams" method="POST">[/b] Choose rating <input type="text" name="jamrate" /> <input type="submit" name="submit1" value="Rate"> </form><br /><br />'; ... ?>As you can see, the form is inside a loop. I am trying to build a rating system. When there is only one row in a database then everything goes smoothly, but if there are more, then the rating applies to all rows. I suppose i need to give different id's to the form. How? Thank you All, I'm getting the following error when I work with a class: Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /webspace/httpdocs/offers/form_key.php on line 5 The complete code for this is class is: <?php class Form_Key { protected $oldKey; public function __construct() { // Ensure we have an available session if ( NULL == session_id() ) { session_start(); } // Grab our former key for validation if ( isset( $_SESSION['form_key'] ) ) { $this->oldKey = $_SESSION['form_key']; } // Assign the new key $_SESSION['form_key'] = md5( uniqid( mt_rand(), TRUE ) ); } public function isValid() { return 'POST' == $_SERVER['REQUEST_METHOD'] && isset( $_POST['form_key'] ) && '' != trim( $_POST['form_key'] ) && '' != trim( $this->oldKey ) && $_POST['form_key'] === $this->oldKey; } public function getKey() { return $_SESSION['form_key']; } public function getOldKey() { return $this->oldKey; } public function render() { return '<input type="hidden" name="form_key" value="' . $_SESSION['form_key'] . '" />'; } public function __toString() { return $this->render(); } } ?> The line that is giving the issue is this line: protected $oldKey; Is it ok just to remove this line?? If I comment it out it gives me the same message but for line 7, which is this one: public function __construct() Anyone have any ideas? Thanks in advance. Code: [Select] $Rep = htmlspecialchars($_GET["Rep"]); echo $Rep; The above will print "John Doe & Assoc." (without the quotes) Code: [Select] $result = mysql_query("SELECT RepName FROM Reps WHERE Repname = '".$Rep."'"); $repcount = mysql_num_rows($result); echo $repcount; The above code prints "0" If I delete the first block of code and replace it with Code: [Select] $Rep = "John Doe & Assoc." The second block of code will then return a "1" as it should. Why is one returning a 0 and one returning a 1 when the text in $Rep appears to be identical in both cases? This problem only appears to be occurring when the $Rep value contains an &. My code looks as follows: include('connectvars.php'); /* REGISTER FORM */ // check if submit button has been clicked if (isset($_POST['submit_signup'])) { // process and assign variables after post submit button has been clicked $user_email = strip_tags(trim($_POST['email'])); $firstname = strip_tags(trim($_POST['firstname'])); $lastname = strip_tags(trim($_POST['lastname'])); $nickname = strip_tags(trim($_POST['nickname'])); $password = $_POST['password']; $repassword = $_POST['repassword']; $dob = $_POST['dob']; $find_us_question = strip_tags(trim($_POST['find_us_question'])); // connect to database $dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); $check_query = "SELECT * FROM users WHERE nickname = '$nickname'"; $check_connect = mysqli_query($dbc, $check_query); $check_count = mysqli_num_rows($check_connect); echo $check_count; die(); It's a register (sign up) page, and it's the beginning of the script, the rest of the script is just checking if all fields are a empty and if the input is in the allowed character length etc. I could it off at die(); because the rest doesn't matter. I want the script to check if the username already exists in the database, so I want mysqli_num_rows to tell me how many rows are already there with the same username, and then I want to continue doing an if statement saying if ($check_count != 0) { echo "Username already exists!" } But the mysqli_num_rows doesn't even print out how many rows there are availible, it gives me an error saying: Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in... The num_rows function worked in the login script the same way, but for some reason it's not working in the register script. Any ideas, what I'm doing wrong? For testing purposes I just want it to print me "1" when I'm entering a username that's already in the database. Hi all, Here's the code I'm using, after opening an IMAP stream to an inbox. The code previous to this opens the inbox, grabs the emails and iterates through them. This bit is checking an individual mail for attachments. Code: [Select] <?php $structure = imap_fetchstructure($mbox, $email_number); $parts = $structure->parts; $fpos=2; for($i = 1; $i < count($parts); $i++) { $message["pid"][$i] = ($i); $part = $parts[$i]; if($part->disposition == 'ATTACHMENT') { // Save the attachment locally to the server // Find the file extension // Save the attachment to DB code here $fpos+=1; } } ?> When I run the script, I get a load of the following reply: Notice: Undefined property: stdClass::$parts in /var/www/html/site/public_html/cron/cron_email_import.php on line XXX Would this mean that there are no actual attachments in the email being processed? Has anyone ever dealt with this function before? All input appreciated. WoolyG i'm using a dropdown menu to add data to URL in order to run a separate query command depending on result.
url comes in as: index.php?role=ceo
i have the following form:
<form action="<?php $_SERVER['PHP_SELF'] ?>" method="GET" > <select name="role"> <option value="all">ALL</option> <option value="ceo">CEO</option> <option value="coceo">Co-Ceo</option> <option value="director">Director</option> <option value="pos">POS Manager</option> <option value="member">Member</option> </select> <input type="submit" value="Filter Results" /> </form>and the following set of if commands; <?php //Check if it echo role (IT DOES!!) echo $role; // Perform the SQL query //if role is set then add WHERE clause to filter to specific role if (isset($_GET['role'])) { $results = mysql_query('SELECT * FROM `ecmt_memberlist` WHERE role = '. $_GET['role'].' ORDER BY CONCAT(MainToon, Name)'); } //if no role set in url return ALL results! else { $results = mysql_query('SELECT * FROM `ecmt_memberlist` ORDER BY CONCAT(MainToon, Name)'); } $results_array = array(); while ($row = mysql_fetch_array($results)) { $results_array[$row['characterID']] = $row; } ?> I have a php page where I have posts about different topic. I have a menu listing all this categories of topics . Some topics may belong to more than one category. So when i click on a particular menu item, the topic belonging to that category will be displayed. While displaying it is in this format---Topic Heading,Belongs to which all categories,date posted and the description. All this are taken from database. Now my actual issue is I am not able to give links to the categories dispalyed ,if the category exceeds more than 1. For eg: Global Warming Posted on March 11,2011 in News, Issue -----------description of global warming goes here. In the above eg: News and issue are the two categories,when i click on News it should display all the items in news category,and when i click on issue it should display all items of issue category. But I am not able to give this link to the categories. Code: [Select] while($row = mysql_fetch_array($q)) { if($row[6]=='News'){ $c='<a href="category_disp.php?category=news">News</a>'; } if($row[6]=='Issues'){ $c='<a href="category_disp.php?category=issues">Issues</a>'; } echo "<tr><td><p >$row[1]</p><br></td></tr>"; echo "<tr><td> <div >". "<p><span>$row[4]</span> <span>". "<a href='$row[6]' >$row[6]|<a href='$row[5]'> Post Comments</a></span></p>". "<p> </p></div><br></td></tr>"; echo "<tr><td><p >$row[2]</p><br></td></tr>"; echo "<tr><td><p ><a href='$row[3]' >Click Here to read more...</a></p></td></tr>"; echo "</div></td></tr>"; } echo" </table> So I wrote this piece of code that for the most part works. The problem is two things. One if I print out say $dir[$i] I get 7 directories back. if I try and store that in an array to later be access by some other function I get up to 24+ C's instead of C:/Path... Code: [Select] public function aisis_get_dir_array($dir){ if(!is_array($dir)){ aisis_get_dir($dir); return; } $count = count($dir); for($i = 0; $i<$count; $i++){ if(!is_dir($dir[$i])){ _e('Specified dir' . $dir[$i] . 'is not a directory.'); } $this->directory_list = $dir[$i]; //store these $handler = opendir($dir[$i]); while($file = readdir($handler)){ if($file != "." && $file != ".."){ $this->files[] = $file; } } } return $this->files; } right under the line: $this->directory_list = $dir[$i]; //store these if You put in echo $dir[$i] you get back directories. How ever down in this function: Code: [Select] public function load_if_extentsion_is_php($dir, $array = false){ $list = array(); $list_dir = array(); if($array == true){ $list = $this->aisis_get_dir_array($dir); $list_dir = $this->directory_list; } else{ $list = $this->aisis_get_dir($dir); } $count = count($list); for($i = 0; $i<$count; $i++){ if($array == true){ $countdir = count($this->directory_list); for($j = 0; $j<$countdir; $j++){ echo $list_dir[$j]; //echo $list_dir[$j]; //echo $list[$i]; } } //if(substr(strrchr($list[$i],'.'),1)=="php"){ //echo $list[$i]; //require_once($dir . $list[$i]); //} } } echoing out: echo $list_dir[$j]; gets you up to 24+ C's instead of the directories that are stored. You can view the whole class at Paste bin - there is an expiry: 12 hours. Essentially you call load_if_extentsion_is_php($dir, $array = false) pass it an array of directories and set the array part to true. To Summarize: If you pass in an array of directories you should get back: a echoed list of directories a echoed list of php files belonging in those directories. Currently you get the later and a series of C's for the first. Why? Am trying to redirect a user based on their login details. it works fine till it get to a particular department.. "Marine Logistics". when i try to log in with ID of someone in that department, it redirects to invalid login page. the code below. what am i missing?
$sql1 = mysql_query("SELECT * FROM users WHERE username = '$username' AND password = '$password'"); $data = mysql_fetch_array($sql1); $department = $data['department']; if ($department== "Admin") { header("Location: admin/dash_admin.php"); exit; } else if ($department == "ICT" ) { if ($data['position'] == "HOD") { header("Location: ICT/HOD/hod_dash.php"); exit; } else{ header("Location: ICT/staff/staff_dash.php"); exit; } exit; } // check if user is in account department else if ($department == "Account" ) { if ($data['position'] == "HOD") { header("Location: account/HOD/account_dash.php"); exit; } else { header("Location: account/staff/staff_dash.php"); exit; } exit; } //check if user is in Supply chain/ Asset Integrity department else if ($department == "Supply Chain/ Asset Integrity" ) { if ($data['position'] == "HOD") { header("Location: supply_chain/HOD/hod_dash.php"); exit; } else{ header("Location: supply_chain/staff/staff_dash.php"); exit; } exit; } // check if user is in manpower department else if ($department == "Manpower" ) { if ($data['position'] == "HOD") { header("Location: manpower/HOD/hod_dash.php"); exit; } else{ header("Location: manpower/staff/staff_dash.php"); exit; } exit; } // check if user is in Business Development Department else if ($department == "Business Development" ) { if ($data['position'] == "HOD") { header("Location: business_development/HOD/hod_dash.php"); exit; } else{ header("Location: business_development/staff/staff_dash.php"); exit; } exit; } // check if user is in HR else if ($department == "HR" ) { if ($data['position'] == "HOD") { header("Location: HR/HOD/hod_dash.php"); exit; } else{ header("Location: HR/staff/staff_dash.php"); exit; } exit; } //check if user is in Marine Logistics Department else if ($department== "Marine Logistics" ) { if ($data['position'] == "HOD") { header("Location: logistics/HOD/hod_dash.php"); exit; } else{ header("Location: logistics/staff/staff_dash.php"); exit; } exit; } //check if user is from Maintenance Department else if ($department == "Maintenance" ) { if ($data['position'] == "HOD") { header("Location: Maintenance/HOD/hod_dash.php"); exit; } else{ header("Location: Maintenance/staff/staff_dash.php"); exit; } exit; } //check if user is from Admin/services Department else if ($department == "Admin / Services" ) { if ($data['position'] == "HOD") { header("Location: admin_services/HOD/hod_dash.php"); exit; } else{ header("Location: admin_services/staff/staff_dash.php"); exit; } exit; } } else{ header("Location: indexWrongPassOrUser.php"); exit; } I have been using some CSS written by Matthew Taylor (www.http://matthewjamestaylor.com), for displaying my web page on iPad orsimilar device. It works in most cases but for some reason it gives strange results when I try to output a table in the main screen area.
It puts the title heading in the right place, but the table for some reason underneath the footer and the page menu disappears completely.
It is usually caused by unclosed div tags, but I have checked them and they appear to be correct.
There is a good explaination of how the CSS works on his web site.
Here is the code for the PHP/HTML:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="generator" content="CoffeeCup HTML Editor (www.coffeecup.com)"> <meta name="dcterms.created" content="Sat, 02 Mar 2013 20:21:23 GMT"> <meta name="description" content=""> <meta name="keywords" content=""> <meta name="viewport" content="width=768px, minium-scale=1.0, maximum-scale=1.0" /> <title></title> <link rel="stylesheet" href="stylesheets/ipad.css" /> <!--[if IE]> <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> </head> <body> <div id="fb-root"> <script>(function(d, s, id) { var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) return; js = d.createElement(s); js.id = id; js.src = "//connect.facebook.net/en_GB/all.js#xfbml=1"; fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'facebook-jssdk'));</script></div><!--end fb-root--> <div id="wrap"> <!--Start wrap--> <div id="header"> <!--Start header--> <img src="images/Head!.png" width="100%" height="150px" alt="" title="" border="0" /> <h1>1066 cards4U</h1> </div><!-- end header --> <div id="content"> <!--Start content--> <div id="main"> <!--Start main--> <h3>Statistics for <? echo $Country; ?> in 2014</h3> <h4>If only the header is shown, there is no data for this country</h4> <?php include('connect_visits.php'); doDB7(); $limitStart = $_POST['QUARTER'] - 13; $Visit_data="SELECT WeekNo.WNo, WeekNo.WCom, Countries.Country, ctryvisits.CVisits FROM ctryvisits LEFT JOIN Countries ON ctryvisits.country = Countries.CID LEFT JOIN WeekNo ON ctryvisits.WNo=WeekNo.WNo WHERE Countries.CID = '{$_POST['country']}' ORDER BY ctryvisits.WNo LIMIT {$limitStart}, 13"; $Visit_data_res = mysqli_query($mysqli, $Visit_data) or die(mysqli_error($mysqli)); $display_block = " <table width=\"20%\" cellpadding=\"3\" cellspacing=\"1\" border=\"1\" BGCOLOR=\"white\" > <tr> <th>Week No</th> <th>Week Commencing</th> <th>Visits</th> </tr>"; while ($C_info = mysqli_fetch_array($Visit_data_res)) { $Cid = $C_info['WNo']; $Visits = ($C_info['CVisits']); $WeekNo = ($C_info['WCom']); //add to display $display_block .= " <tr> <td width=\"1%\" valign=\"top\">".$Cid."<br/></td> <td width=\"8%\" valign=\"top\">".$WeekNo."<br/></td> <td width=\"5%\" valign=\"top\">".$Visits."<br/></td> </td></tr>"; } mysqli_free_result($Visit_data_res); $CNo2Cty ="SELECT CID, Country FROM Countries WHERE CID='{$_POST['country']}'"; $CNo2Cty_res =mysqli_query($mysqli, $CNo2Cty) or die(mysqli_error($mysqli)); if (mysqli_num_rows($CNo2Cty_res)<1){ $display_block="<p><em>Invalid Country, Please try again</em></p>"; } while ($C_name = mysqli_fetch_array($CNo2Cty_res)) { } mysqli_free_result($CNo2Cty_res); //mysqli_close(mysqli); ?> <?php echo $display_block; ?> <div class="fb-comments" data-href="http://www.1066cards4u.co.uk" data-width="470"></div><br /> <div class="fb-like" data-href="http://www.1066cards4u.co.uk" data-send="true" data-layout="box_count" data-width="300" data-show-faces="true" data-font="arial"></div> <!-- end fb-like --> </div> <!--end main--> <div id="side"> <!--Start side--> <div id="sidea"> <!--Start sidea--> <h3>Main Menu</h3> <p><ul> <li><a href="index1.html">Home</a></li> <li><a href="iLinks.html">Links</a></li> <li><a href="iTechniques.html">Techniques</a></li> <li><a href="iVerse_Menu.html">Verse's</a></li> <li><a href="icontact.html">Contact Us</a></li> <li><a href="iblog.php">Blog</a></li> <li><a href="iAboutUs.html">About Us</a></li> <li><a href="iGallery.html">Gallery</a></li> <li><a href="iStats_Menu.html">Stats</a></li> <li><a href="iRelHol_Menu.html">Religious Holiday's</a></li> <li><a href="iSub_form.html">Subscribe to Newsletter</a></li> </ul></p> </br> </div> <!--end sidea--> <div id="sideb"> <!--Start sideb--> </div> <!--end sideb--> <div id="sidec"> <!--Start sidec--> </div> <!--end sidec--> </div> <!--end side--> </div> <!--end content--> <div id="footer"> <!--Start footer--> <p>© 2012 Content:1066 Cards 4U. All rights reserved. <br /> With thanks to Matt Taylor - matthewjamestaylor.com</p> </div> <!--end footer--> </div> <!--end wrap--> </body> </html>Here is the CSS: * { margin:0; padding:0; } h2 { padding:1em 0 0 0; } p { line-height:1.4em; } p + p { text-indent:2em; } body { font-size:100%; text-align:center; background:#ddd; } pre { display:block; margin:1em 0 0 0; width:488px; } pre code { background:#eee; display:block; padding:10px; } .r { float:right; padding:0 0 10px 20px; } /* Landscape mode (default) */ #wrap { margin:0 auto; width:1024px; position:relative; overflow:hidden; text-align:left; background:#fff; } #header { float:left; width:1024px; padding:10px 0 20px 0; background:#fff; border-bottom:1px solid #000; } #header h1 { padding:10px 30px 0 30px; } #header p { padding:0 30px; line-height:1.4em; } #content { float:left; width:1024px; background:#eee; position:relative; left:768px; } #main { float:left; width:708px; position:relative; right:738px; padding:20px 0; } #side { float:right; width:216px; position:relative; right:788px; padding-bottom:20px; } #sidea, #sideb, #sidec { clear:left; float:left; width:216px; } #footer { clear:both; float:left; width:1024px; border-top:1px solid #000; background:#ddd; } #footer p { padding:20px 30px; } @media only screen and (orientation:portrait){ /* portrait mode */ #header, #wrap, #footer { } #content { left:0; background:#fff; } #main { float:left; width:708px; position:relative; right:0; left:30px; padding:20px 0; } #side { clear:left; float:left; width:768px; right:0; padding-bottom:20px; background:#eee; } #sidea { clear:none; width:216px; float:left; position:relative; left:30px; padding-top:20px; } #sideb { clear:none; width:216px; float:left; position:relative; left:60px; padding-top:20px; } #sidec { clear:none; width:216px; float:right; position:relative; right:30px; padding-top:20px; } #footer { position:absolute; bottom:0; width:100%; height:60px; /* Height of the footer */ background:#6cf; width:768px; } }I have spent hours trying different things, but I can't find a solution. I believe its a CSS problem, but if you think it is HTML can the moderator move it? Your help would be appreciated. I am trying to split a simple string from my db it is in the format #/# 1/5 2/5 3/3 4/2 etc... I have the following: Code: [Select] echo $value.'<BR>'; $temp=explode('/',$value['field']); print_r($temp); echo '<br>'; when I execute the above (it's in a for loop) I get the following output 1/5 Array ( => 1 ) 2/5 Array ( => 2 ) 3/3 Array ( => 3 ) 4/2 Array ( => 4 ) I am expecting 1/5 Array ( => 1 [1] => 5) for the first entry and so on down the line showing both values after the explode. Hello, this is my first post in this forum, in fact my first post about php. I am developing a crud application, but when i am trying to list a set of results it gives me more that the expected Let me explain. if i print_r my array (which i get it from a sql result) it gives me this Array ( => SHR1 [codprod] => SHR1 [1] => REGULAR SERVICE HOUR [proddescription] => REGULAR SERVICE HOUR [2] => 3.00 [qty] => 3.00 [3] => HR Code: [Select] => HR [4] => 45.0000 [price] => 45.0000 [5] => 0.00 [discount] => 0.00 [6] => 135.00 [amount] => 135.00 ) [/li][/list] if I foreach($detailrow as $value){ echo $detailrow['codprod'] . ", " . $detailrow['proddescription'] . ", " . $detailrow['qty'] . ", " . $detailrow['code'] . ", " . $detailrow['price'] . ", " . $detailrow['discount'] . ", " . $detailrow['amount'] . "<br/>"; } It gives me 14 rows with the same info. I run the query in mysql and it gives me only 1 result as expected. I noticed that the 14 rows are the same quantity of items in the array not results but let say columns, i dont know if it has something to do with the results. My questions: Why it is giving me 14 rows instead just one? What is the $value in the foreach function? why can't i just say foreach($myarray)? why the print_r shows me the items array duplicated using the array position and the item name? Thank you for your help!! |