Search Results

Search found 42698 results on 1708 pages for 'php in array'.

Page 160/1708 | < Previous Page | 156 157 158 159 160 161 162 163 164 165 166 167  | Next Page >

  • Adding with PHP to a MySQL database

    - by shinjuo
    I am pretty new to PHP and I am trying to make an inventory database. I have been trying to make it so that a user can enter a card ID and then amount the want to add to the inventory and have it update the inventory. For example someone could type in test and 2342 and it would update test. Here is what I have been trying with no success: add.html <body> <form action="add.php" method="post"> Card ID: <input type="text" name="CardID" /> Amount to Add: <input type="text" name="Add" /> <input type="submit" /> </form> </body> </html> add.php <?php $link = mysql_connect('tulsadir.ipowermysql.com', 'cbouwkamp', '!starman1'); if (!$link){ die('Could not connect: ' . mysql_error()); } mysql_select_db("tdm_inventory", $link); $add = $_POST[Add] mysql_query("UPDATE cardLists SET AmountLeft = '$add' WHERE cardID = 'Test'"); echo "test successful"; mysql_close($link); ?>

    Read the article

  • PHP IIS problems downloading file says it is corrupt

    - by Matt
    Hi, I am running PHP on IIS 6 with mssql. I have uploaded a file to my webserver through a php script. Upon checking the file on the server the file is ok and not corrupt. However, when i then have a link on my website to try and download the file, it says the file is corrupt. I know the file isnt corrupt as i can view it perfectly if i look at the file on the server. Is seems like this is a common problem as a similar problem was posted here: http://www.bigresource.com/Tracker/Track-php-1pAakBhT/ Any help would be much appreciated. Thanks, M My download code is as follows: $filesize = $rows->filesize; $filepath = $rows->filepath; header("Content-Disposition: attachment; filename=$filename"); header("Content-length: $filesize"); header("Content-type: application/pdf"); header("Cache-control: must-revalidate"); header("Content-Description: PHP Generated Data"); readfile($filepath);

    Read the article

  • PHP - How can I check if return() was called from an include()'d file?

    - by John Himmelman
    How can I tell if return() was called from within the included file. The problem is that include() returns 'int 1', even if return() wasn't called. Here is an example... included_file_1.php <?php return 1; included_file_2.php <?php echo 'no return here, meep'; main.php <?php $ret = include('included_file_1.php'); // This file DID return a value, int 1, but include() returns this value even if return() wasn't called in the included file. if ($ret === 1) { echo 'file did not return anything'; } var_dump($ret); $ret = include('included_file_2.php'); // The included file DID NOT return a value, but include() returns 'int 1' if ($ret === 1) { echo 'file did not return anything'; } var_dump($ret);

    Read the article

  • PHP: Use a string as an array index path to retreive a value.

    - by Charles
    Say I have an array like: Array ( [0] => Array ( [Data] => Array ( [id] => 1 [title] => Manager [name] => John Smith ) ) [1] => Array ( [Data] => Array ( [id] => 1 [title] => Clerk [name] => ( [first] => Jane [last] => Smith ) ) ) ) I want to be able to build a function that I can pass a string to that will act as the array index path and return the appropriate array value without using eval(). Is that possible? function($indexPath, $arrayToAccess) { //$indexPath would be something like [0]['Data']['name'] which would return //"Manager" or it could be [1]['Data']['name']['first'] which would return //"Jane" but the amount of array indexs that will be in the index path can //change, so there might be 3 like the first example, or 4 like the second. return $arrayToAccess[$indexPath] <-obviously wont work }

    Read the article

  • Translating 3-dimensional array reference onto 1-dimensional array

    - by user146780
    If there is an array of ar[5000] then how could I find where element [5][5][4] would be if this was a 3 dimensional array? Thanks I'm mapping pixels: imagine a bimap of [768 * 1024 * 4] where would pixel [5][5][4] be? I want to make this: static GLubyte checkImage[checkImageHeight][checkImageWidth][4]; static GLuint texName; bool itt; void makeCheckImage(void) { Bitmap *b = new Bitmap(L"c:/boo.png"); int i, j, c; Color cul; for (i = 0; i < checkImageHeight; i++) { for (j = 0; j < checkImageWidth; j++) { b->GetPixel(j,i,&cul); checkImage[i][j][0] = (GLubyte) cul.GetR(); checkImage[i][j][1] = (GLubyte) cul.GetG(); checkImage[i][j][2] = (GLubyte) cul.GetB(); checkImage[i][j][3] = (GLubyte) cul.GetA(); } } delete(b); } work without making a multidimensional array. width = 512, height = 1024....

    Read the article

  • Unzip .zip file uploaded from Android via PHP to IIS 7

    - by HaOx
    I'm sending compressed file in .zip extension from Android via PHP to IIS server. Almost is working everything, but I cannot achieve unzip files with php. I've this code: <?php $target_path1 = "C:/Windows/Temp/"; $target_path1 = $target_path1 . basename( $_FILES['uploaded_file']['name']); /* I'm making the folder */ $directorio = substr($target_path1, 0, 32); if (!is_dir($directorio)) { mkdir($directorio); } /* I declare a path */ $barra = "/"; $target_path1 = $directorio . $barra . basename( $_FILES['uploaded_file']['name']); $target_path2 = $directorio . $barra; if(move_uploaded_file($_FILES['uploaded_file']['tmp_name'], $target_path1)) { /* Here I want to unzip the uploaded file */ } else{ echo "There was an error uploading the file, please try again!"; echo "filename: " . basename( $_FILES['uploaded_file']['name']); echo "target_path: " .$target_path1; } ?> So, how can I unzip uploaded file? I tried so many methods but no one worked. I'd be appreciated if someone could tell what I have to do to unzip the uploaded file. And if I have to configure some parameters in php.ini or IIS server. Thanks in advance.

    Read the article

  • php script randomly hangs up

    - by sergdev
    I install php 5 (more precisely 5.3.1) as apache module. After this one of my application becomes randomly hang up on mysql_connect - sometimes works, sometimes no, sometimes reload of page helps. How can this be fixed? I use Windows Vista, Apache/2.2.14 (Win32) PHP/5.3.1 with php module, MySql 5.0.67-community-nt. After a minute I obtain the error message: Fatal error: Maximum execution time of 60 seconds exceeded in path\to\mysqlcon.php on line 9 I run MySql locally and heavy load could not be a reason: SHOW PROCESSLIST shows about 3 process SHOW VARIABLES LIKE 'MAX_CONNECTIONS' is 100. UPDATE: At first I thought that this is connected with mysql_connect. But now I can't say for certain. More difficult thing is when I insert the line to debug: $fh = fopen("E://_debugLog", 'a'); fwrite($fh, __FILE__ . " : " . __LINE__ . "\n"); fclose($fh); script start working near that location as a rule.

    Read the article

  • PHP class to C# class?

    - by LordSauron
    I work for a company that makes application's in C#. recently we got a customer asking us to look in to rebuilding an application written in PHP. This application receives GPS data from car mounted boxes and processes that into workable information. The manufacturer for the GPS device has a PHP class that parses the received information and extracts coordinates. We were looking in to rewriting the PHP class to a C# class so we can use it and adapt it. And here it comes, on the manufacturers website there is a singel line of text that got my skin krawling: "The encoding format and contents of the transmitted data are subject to constant changes. This is caused by implementations of additional features by new module firmware versions which makes it virtually impossible to document it and for you to properly decode it yourself." So i am now looking for a option to use the "constantly changing" PHP class and access it in C#. Some thing link a shell only exposing some function's i need. Except i have no idea how i can do this. Can any one help me find a solution for this.

    Read the article

  • Dividing numbers between rows in MySQL + PHP

    - by André Figueira
    Hi I am working on a kind of raffle system which divides 1 million random numbers into an x amount of tickets, e.g. 1 million random numbers to 10,000 tickets. Each ticket is a row in a database, we then have another table ticket numbers in which i need to give 100 numbers to each ticket they are related by the ticket id. So at the moment this is my code: //Amount of the 1 million tickets divided to the tickets $numbersPerTickets = $_POST['numbersPerTicket']; //The total cost of the property $propertyPrice = $_POST['propertyPrice']; //The total amount of tickets $totalTickets = NUMBER_CIELING / $numbersPerTickets; //The ticket price $ticketPrice = $propertyPrice / $totalTickets; //Generate array with random numbers up to 999,999 $randomTicketNumbers = createTicketNumbers(); //Creation loop counter $ticketCreationCount = 1; //Loop and create each ticket while($ticketCreationCount <= $totalTickets) { //Create a padded ticket number $ticketNumber = str_pad($ticketCreationCount, 6, 0, STR_PAD_LEFT); $query = ' INSERT INTO tickets( propertyID, ticketNumber, price ) VALUES( "'.$propertyID.'", "'.$ticketNumber.'", "'.$ticketPrice.'" ) '; $db->query($query); //Get the ID of the inserted ticket to use to insert the ticket numbers $ticketID = $db->insert_id; $loopBreak = $numbersPerTickets; $addedNumberCount = 1; foreach($randomTicketNumbers as $key => $value) { $query = ' INSERT INTO ticketNumbers( ticketID, number ) VALUES( "'.$ticketID.'", "'.$value.'" ) '; $db->query($query); unset($randomTicketNumbers[$key]); if($addedNumberCount == $loopBreak){ break; }else{ $addedNumberCount++; } } $ticketCreationCount++; } But this isn't working it adds the right amount of tickets, which in the case for testing is 10,000 but then adds far too many ticket numbers, it ends up exceeding the million numbers in the random tickets array, The random tickets array is just a simple 1 tier array with 1 million numbers sorted randomly.

    Read the article

  • Using array instead of lots of db queries in PHP

    - by Tural Teyyuboglu
    My function looks like that. It works but does lots of work (recursively calls itself and does lots of db queries.). There must be another way to do same thing but with array (with one query). I can't figure out how to modify this function to get it work with array. Please help. function genMenu($parent, $level, $menu, $utype) { global $db; $stmt=$db->prepare("select id, name FROM navigation WHERE parent = ? AND menu=? AND user_type=?") or die($db->error); $stmt->bind_param("iii", $parent, $menu, $utype) or die($stmt->error); $stmt->execute() or die($stmt->error); $stmt->store_result(); /* bind variables to prepared statement */ $stmt->bind_result($id, $name) or die($stmt->error); if ($level > 0 && $stmt->num_rows > 0) { echo "\n<ul>\n"; } while ($stmt->fetch()) { echo "<li>"; echo '<a href="?page=' . $id . '">' . $name . '</a>'; //display this level's children genMenu($id, $level+1, $menu, $utype); echo "</li>\n\n"; } if ($level > 0 && $stmt->num_rows > 0) { echo "</ul>\n"; } $stmt->close(); }

    Read the article

  • how to pass session_id() throught out the php pages?

    - by Piyush
    when user clicks on login button(index.php) I am calling chechlogin.php where I am checking loginId an password as- if($count==1) { // Register $myusername, $mypassword and redirect to file "login_success.php" session_register("myusername"); session_register("mypassword"); $_SESSION['UserId'] = $myusername; $_session['SessionId'] = session_id(); header("location:LoggedUser.php"); } in LiggedUser.php <?php session_start(); //starting session if (!isset($_SESSION['SessionId']) || $_SESSION['SessionId'] == '') { header("location:index.php"); } ? Problem: It is always going back to index.php page although I am entering right userid and password.I think session_id() is not working properly or ??

    Read the article

  • Connection to mysql works through php but not through a form submission?

    - by Legend
    I have a download.php file that connects to a remote mysql database. If I run it using php download.php it works fine. But if I create another php file form.php and then submit the form to this download.php, it complains the following: Can't connect to MySQL server on '<IP_ADDRESS>' (13) Does anyone know why this might be happening? I can't see a reason why this works directly but fails to work upon form submission...

    Read the article

  • php lampp permissions of fopen function

    - by marmoushismail
    hi i'm programming php using: netbeans 6.8 lampp for ubuntu (xampp) apache which came with xampp $fh = fopen("testfile2.txt", 'w') or die("Failed to create file"); $text ="hello man cool good"; fwrite($fh, $text) or die("Could not write to file"); fclose($fh); echo "File 'testfile.txt' written successfully"; //i get the next error: Warning: fopen(testfile2.txt) [function.fopen]: failed to open stream: Permission denied in /home/marmoush/allprojects/phpprojects/myindex.php on line 91 Failed to create file anyway i know what this error is; it's about folder and files permissions; i looked into the folder permission tab made access available for "others" group ( to read and write) the program worked result was a file (test.txt) so i looked at the created file permission it appears to be that (php , xampp or whoever) creates file with (nobody permission) I have 2 QUESTIONS: 1- what if i need the file created by (php code and xampp ) to have the "root or user or myname" permissions ?? where to set this setting 2-also my concern (what if i send this files to actual web server will it make nobody permissions also nobody ? when they create files

    Read the article

  • PHP Foreach statement issue. Multiple rows are returned

    - by Daniel Patilea
    I'm a PHP beginner and lately i've been having a problem with my source code. Here it is: <html> <head> <title> Bot </title> <link type="text/css" rel="stylesheet" href="main.css" /> </head> <body> <form action="bot.php "method="post"> <lable>You:<input type="text" name="intrebare"></lable> <input type="submit" name="introdu" value="Send"> </form> </body> </html> <?php //error_reporting(E_ALL & ~E_NOTICE); mysql_connect("localhost", "root", "") or die(mysql_error()); mysql_select_db("robo") or die(mysql_error()); $intrebare=$_POST['intrebare']; $query = "SELECT * FROM dialog where intrebare like '%$intrebare%'"; $result = mysql_query($query) or die(mysql_error()); $row = mysql_fetch_array($result) or die(mysql_error()); ?> <div id="history"> <?php foreach($row as $rows){ echo "<b>The robot says: </b><br />"; echo $row['raspuns']; } ?> </div> It returns me the result x6 times. This problem appeared when I've made that foreach because I wanted the results to stuck on the page one by one after every sql querry. Can you please tell me what seems to be the problem? Thanks!

    Read the article

  • Upload to a PHP Server, using Ajax ( XMLHttp POST)

    - by Krishnanunni
    Right now i'm using the below method to Upload a file to PHP <form enctype="multipart/form-data" action="http://sserver.com/fileupload.php" method="POST"> <input type="hidden" name="MAX_FILE_SIZE" value="30000000" /> <input type="hidden" name="filename" value="file_uploaded.gif" /> <input type="hidden" name="username" value="foobar"/> Please choose a file: <input name="uploaded" type="file" /><br /> <input type="submit" value="Upload" /> </form> I read the $_POST and $_FILE in php to complete upload like this. $target = $_SERVER['DOCUMENT_ROOT']."/test/upload/"; $target = $target . basename( $_FILES['uploaded']['name']) ; echo $target; $ok=1; if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target)) { echo "The file ". basename( $_FILES['uploaded']['name']). " has been uploaded"; } else { echo "Sorry, there was a problem uploading your file."; } My questions is , can i change the above said code (HTML) to an Ajax XMLHttpRequest without changes in PHP.

    Read the article

  • PHP: parse $_FILES[] data in multidimesional array

    - by superUntitled
    I having been looking around for an answer to this and have not found an answer anywhere, I am hoping someone has done this before! I have a form that allows for dynamic duplication of the form fields. The form allows for file uploads and text input, so the data is sent in both $_POST and $_FILES arrays. The the initial set of inputs look like this: <input type="text" name="primary[1][text]" /> <input type="file" name="primary[1][file]" /> <input type="text" class="a" name="secondary[1][text][]" /> <input type="file" name="secondary[1][file][]" /> When duplicated the fields are incremented, they look like this: <input type="text" name="primary[2][text]" /> <input type="file" name="primary[2][file]" /> <input type="text" class="a" name="secondary[2][text][]" /> <input type="file" name="secondary[2][file][]" /> To complicate matters, the "secondary" form fields can also be duplicated (thus the [] at the end of the secondary name array. How can I parse the posted $_FILES array? I have tried something like this: foreach ($_FILES['question'] as $f_num) { echo $f['file']['name']; } but I get an "Undefined index: file... " error.

    Read the article

  • PHP: parse $_FILES[] data in multidimesional array

    - by superUntitled
    Example form here: http://jsfiddle.net/superuntitled/uaTtx/1/ I have a form that allows for dynamic duplication of the form fields. The form allows for file uploads and text input, so the data is sent in both $_POST and $_FILES arrays. The the initial set of inputs look like this: <input type="text" name="question[1][text]" /> <input type="file" name="question[1][file]" /> <input type="text" class="a" name="answer[1][text][]" /> <input type="file" name="answer[1][file][]" /> When duplicated the fields are incremented, they look like this: <input type="text" name="question[2][text]" /> <input type="file" name="question[2][file]" /> <input type="text" class="a" name="answer[2][text][]" /> <input type="file" name="answer[2][file][]" /> To complicate matters, the "answer" form fields can also be duplicated (thus the [] at the end of the 'answer' name array. How can I parse the posted $_FILES array? I have tried something like this: foreach ($_FILES['question'] as $p_num) { echo $p_num['file']['name']; foreach ($_FILES['answer'] as $a_num) { echo $a_num['file']['name']; } } but I get an "Undefined index: file... " error. How can I parse out the posted values.

    Read the article

  • using a href (html)tag along with PHP

    - by dexter
    i have tried: <?php include("delete.php") ?> <?php .... .... .... if($result=mysql_query($sql)) { echo "<table><th>Id</th><th>Name</th><th>Description</th><th>Unit Price</th>"; while($row = mysql_fetch_array($result)) { echo "<tr><td>".$row['Id']."</td><td>".$row['Name']."</td><td>".$row['Description']."</td><td>".$row['UnitPrice']."</td> <td><a href='delproduct($row[Id])' onclick = 'return MsgOkCancel()'>Delete</a></td></tr>"; echo "<br/>"; } } ?> following javascript is in the same page: <script type="text/javascript" language="javascript"> function MsgOkCancel() { if (confirm("Are You Sure You Want to Delete?")) { return true } else {return false} } </script> where delproduct is a javascript function in delete.php written like: <script type="javascript"> function delproduct(Id) { alert('Id '+ Id); } <script> ** after ** clicking Delete a okcancel message-box appear asking conformation ** but ** after clicking 'ok' it should execute statements inside delproduct function but it doesn't it gives error like: Object Not Found :The requested URL was not found on this server. what would be the problem? pls help, thanks

    Read the article

  • Write to PDF using PHP from android device

    - by Brent Mitchell
    I am trying to write to a pdf file on php server. I have sent variables to the server, create the pdf document, then have my phone download the document to view on device. The variables seem not to write on the php file. I have my code below public void postData() { try { Calculate calc = new Calculate(); HttpClient mClient = new DefaultHttpClient(); StringBuilder sb=new StringBuilder("myurl.com/pdf.php"); HttpPost mpost = new HttpPost(sb.toString()); String value = "1234"; List nameValuepairs = new ArrayList(1); nameValuepairs.add(new BasicNameValuePair("id",value)); mpost.setEntity(new UrlEncodedFormEntity(nameValuepairs)); } catch (UnsupportedEncodingException e) { Log.w(" error ", e.toString()); } catch (Exception e) { Log.w(" error ", e.toString()); } } And my php code to write the variable "value" onto the pdf document: //code to reverse the string if($_POST[] != null) { $reversed = strrev($_POST["value"]); $this->SetFont('Arial','u',50); $this->Text(52,68,$reversed); } I am just trying to write the variable in a random spot, but the variable the if statement is always null and I do not know why. Thanks. Sorry if it is a little sloppy.

    Read the article

  • SQL return ORDER BY result as an array

    - by EarthMind
    Is it possible to return groups as an associative array? I'd like to know if a pure SQL solution is possible. Note that I release that I could be making things more complex unnecessarily but this is mainly to give me an idea of the power of SQL. My problem: I have a list of words in the database that should be sorted alphabetically and grouped into separate groups according to the first letter of the word. For example: ape broom coconut banana apple should be returned as array( 'a' => 'ape', 'apple', 'b' => 'banana', 'broom', 'c' => 'coconut' ) so I can easily created sorted lists by first letter (i.e. clicking "A" only shows words starting with a, "B" with b, etc. This should make it easier for me to load everything in one query and make the sorted list JavaScript based, i.e. without having to reload the page (or use AJAX). Side notes: I'm using PostgreSQL but a solution for MySQL would be fine too so I can try to port it to PostgreSQL. Scripting language is PHP.

    Read the article

  • Increasing understanding of validating a string with PHP string functions

    - by user1554264
    I've just started attempts to validate data in PHP and I'm trying to understand this concept better. I was expecting the string passed as an argument to the $data parameter for the test_input() function to be formatted by the following PHP functions. trim() to remove white space from the end of the string stripslashes() to return a string with backslashes stripped off htmlspecialchars() to convert special characters to HTML entities The issue is that the string that I am echoing at the end of the function is not being formatted in the way I desire at all. In fact it looks exactly the same when I run this code on my server - no white space removed, the backslash is not stripped and no special characters converted to HTML entities. My question is have I gone about this in the wrong approach? Should I be creating the variable called $santised_input on 3 separate lines with each of the functions trim(), stripslashes() and htmlspecialchars()? By my understanding surely I am overwriting the value of the $santised_input variable each time I recreate it on a new line of code. Therefore the trim() and stripslashes() string functions will never be executed. What I am trying to achieve is using the "$santised_input" variable to run all of these PHP string functions when the $data argument is passed to my test_input() function. In other words can these string functions be chained together so that I only need to create $santised_input once? <?php function test_input($data) { $santised_input = trim($data); $santised_input = stripslashes($data); $santised_input = htmlspecialchars($data); echo $santised_input; } test_input("%22%3E%3Cscript%3Ealert('hacked')%3C/script%3E\ "); //Does not output desired result "&quot;&gt;&lt;script&gt;alert('hacked')&lt;/script&gt;" ?>

    Read the article

  • Why is my php script freezing?

    - by William
    What is causing my php code to freeze? I know it's cause of the while loop, but I have $max_threads--; at the end so it shouldn't do that. <html> <head> <?php $db = mysql_connect("host","name","pass") or die("Can't connect to host"); mysql_select_db("dbname",$db) or die("Can't connect to DB"); $sql_result = mysql_query("SELECT MAX(Thread) FROM test_posts", $db); $rs = mysql_fetch_row($sql_result); $max_threads = $rs[0]; $board = $_GET['board']; ?> </head> <body> <?php While($max_threads >= 0) { $sql_result = mysql_query("SELECT MIN(ID) FROM test_posts WHERE Thread=".$max_threads."", $db); $rs = mysql_fetch_row($sql_result); $sql_result = mysql_query("SELECT post FROM test_posts WHERE ID=".$rs[0]."", $db); $post = mysql_fetch_row($sql_result); $sql_result = mysql_query("SELECT name FROM test_posts WHERE ID=".$rs[0]."", $db); $name = mysql_fetch_row($sql_result); $sql_result = mysql_query("SELECT trip FROM test_posts WHERE ID=".$rs[0]."", $db); $trip = mysql_fetch_row($sql_result); if(!empty($post)) echo'<div class="postbox"><h4>'.$name[0].'['.$trip[0].']</h4><hr />' . $post[0] . '<br /><hr />[<a href="http://prime.programming-designs.com/test_forum/viewthread.php?thread='.$max_threads.'">Reply</a>]</div>'; $max_threads--; } ?> </body> </html>

    Read the article

  • Redirecting Pages with PHP causing problems

    - by psp
    I have a page which has a link to a php page which takes data from $_GET and updates a database. After that it returns the user to the homepage with: header("Location: http://localhost/"); The thing is that this seems to "interrupt" the mysql part of the code. If I remove this redirect, everything in the database is updated, but when I put it back, nothing gets updated... This is the database update code, I am using a class of mine as a mysql wrapper: $conn->where('hash',$data1['hash']); $conn->update(TABLE_ITEMS,$newData1); $conn->where('hash',$data2['hash']); $conn->update(TABLE_ITEMS,$newData2); Notes: -There is no text or echo()'s on the page and no space before the <?php tag Order of Code: Data received from $_SESSION and $_GET Data processed and placed into arrays Data placed into mysql database header(); used to redirect page Code <?php require_once('config.php'); import(); if ( isset ( $_GET['g'] ) && isset ( $_SESSION['itemA'] ) && isset ( $_SESSION['itemB'] ) ) { $itemA = $_SESSION['gameA']; $itemB = $_SESSION['gameB']; $newData1 = processData($itemA); $newData2 = processData($itemB); $conn->update(TABLE_ITEMS,$newData1); $conn->update(TABLE_ITEMS,$newData2); header('Location: http://localhost/'); } else { header('Location: http://localhost/'); }

    Read the article

  • I want to store a php $_SESSION variable and retrieve it on another page.

    - by CDeanMartin
    <?php session_start(); // store session data $_SESSION['count']=0; ?> <html><head></head> <body> <?php include ("getElement.php"); echo getLinkButton("myscript.php", "myscript.php"); echo $_SESSION['count']++; ?> </body> </html> The code above works, but when I click the link to navigate to myscript.php: <?php echo $_SESSION['count']; ?> I get this error: Undefined variable: _SESSION in /home/ubuntu/public_html/myscript.php on line 2

    Read the article

  • PHP classes, parse syntax errors when using 'var' to declare variables

    - by jon
    I am a C# guy trying to translate some of my OOP understanding over to php. I'm trying to make my first class object, and are hitting a few hitches. Here is the beginning of the class: <?php require("Database/UserDB.php"); class User { private var $uid; private var $username; private var $password; private var $realname; private var $email; private var $address; private var $phone; private var $projectArray; public function _construct($username) { $userArray = UserDB::GetUserArray($username); $uid = $userArray['uid']; $username = $userArray['username']; $realname = $userArray['realname']; $email = $userArray['email']; $phone = $userArray['phone']; $i = 1; $projectArray = UserDB::GetUserProjects($this->GetID()); while($projectArray[$i] != null) { $projectArray[$i] = new Project($projectArray[$i]); } UserDB.php is where I have all my static functions interacting with the Database for this User Class. I am getting errors using when I use var, and I'm getting confused. I know I don't HAVE to use var, or declare the variables at all, but I feel it is a better practice to do so. the error is "unexpected T_VAR, expecting T_VARIABLE" When I simply remove var from the declarations it works. Why is this?

    Read the article

< Previous Page | 156 157 158 159 160 161 162 163 164 165 166 167  | Next Page >