812 Posted Topics

Member Avatar for gopi17

The javascript function ConfirmChoice() should should be somehow told the ID of the user to delete. It could be read from the chosen option of the select element. So the select element should be assigned an ID (for accessing with javascript) and the options have to have values: <tr><td><select name="id" …

Member Avatar for broj1
0
257
Member Avatar for Venter

The connect function lacks the connection functionality and lacks a returns statement. You should add a connect function `mysql_connect` which returns a valid link (or an error): private function connect() { $this->link = mysql_connect($this->server, $this->username, $this->password); $result= mysql_select_db($this->db, $this->link) or die('sql error'); return mysql_connect() or die('Could not connect: ' . …

Member Avatar for pritaeas
0
846
Member Avatar for jahidshumon

Set up a web server, a database, maybe a PHP framework or libraries. Pick a good editor (a lot of people prefer Eclipse). Write a hello world or a phpinfo program and test if everything works together. Now you are ready to start thinking what would be a useful app …

Member Avatar for veedeoo
0
224
Member Avatar for siddharth.dixit.5243

Welcome on DW from me too. There is a nice article [here](http://www.daniweb.com/web-development/php/threads/435023/read-this-before-posting-a-question) about how to participate on the forum (this or any other) to get the most out of it. We will be more than glad to help once we get a proper question.

Member Avatar for gon1387
0
189
Member Avatar for abeer.rao

This is not strictly a PHP question, maybe it would be better to seek help in [HTML](http://www.daniweb.com/web-development/web-design-html-and-css/threads/444421/custom-mobile-site) forum on DW. But anyway, html code seem to be OK. Check whether the paths in the href attribute are correct. What exactly does happen when you click on particular link?

Member Avatar for Webville312
0
167
Member Avatar for sagisgirl

When you use values from forms in your query best practices are: - check for existence of values - validate entered values for correct type/value - escape the values to prevent entering bad characters (like `'`) // check if there is a value in the request if(isset($_REQUEST['tid']) && !empty($_REQUEST['tid'])) { …

Member Avatar for sagisgirl
0
163
Member Avatar for unikorndesigns

I am not familiar with Codeigniter but it seems that in the last foreach loop you are overwriting the same element (`$finalarray["row"]`) over and over again: $finalarray["row"]=implode("|",$item); I do not know what the end result should be. If it should be string then you should use concatenation. If on the …

Member Avatar for unikorndesigns
0
189
Member Avatar for guilherme.carvalho.9250

Your approach is completely OK, I think most of people do it this way. You start a html table, display a header row and then loop through the resultset from a mysql query and display each row, adding a delete and edit links. The only thing that could be done …

Member Avatar for guilherme.carvalho.9250
0
1K
Member Avatar for alex.p.kcx

Once you query the database you can retrieve a row in either: - an array (associative: using mysql_fetch_assoc or enumerated using mysql_fetch_row or both using mysql_fetch_array) where keys are field names (or filed index) and values are the values you queried: $myArray['username'] = 'broj1'; $myArray['password'] = 'IamNotTellingIt'; or - an …

Member Avatar for broj1
0
384
Member Avatar for brizleciderarmy

mysqli_fetch_assoc function returns only one row. You use a while loop to go through all the rows (10 in your case) but the way you implemented your function this is not happening. If you want to use this function to return all results, you have to read all the rows …

Member Avatar for brizleciderarmy
0
166
Member Avatar for mantapgan

If you want to use this function outside the object make it public. public function getAktiva(){ return $this->aktivaLancar+$this->aktivaTetap; } This is usually the purpose of the get functions (getters): to get the data stored in protected or private variables.

Member Avatar for broj1
0
497
Member Avatar for GraficRegret

One possibility for the cause of the error could be on the return line of the login function (which obviously returns false): return(mysql_result($query, 0) === 1) ? $user_id : false; `mysql_result()` function returns string so you should compare it to `1` (an integer) with `==` operator. If you want to …

Member Avatar for bpinkston1
0
212
Member Avatar for chira.laura.9

Please post the insert_validation.php script also since the values should be accessible there (assuming that the queries return expected values).

Member Avatar for broj1
0
347
Member Avatar for din3sh

To add a new fibonacci number on each refresh you should store each previous and current value in a session. session_start(); // on the beginning you have 0 and 1 if(!isset($_SESSION['previous']) || !isset($_SESSION['current'])) { $_SESSION['previous'] = 0; $_SESSION['current'] = 1; echo $_SESSION['previous']; echo ' '; echo $_SESSION['current']; } else { …

Member Avatar for broj1
0
253
Member Avatar for missy_mi

The code on lines 16 to 20 is a bit suspicious: if (!isset($_GET['Page'])) { //Instruction if $_POST['value']doesnt exist $_GET['Page']="%"; } `$_GET['Page']` is supposed to be an integer, isn't it? In some circumstances the `$Page` variable could be assigned a value of `%` and the query would fail since `$Page_Start` and …

Member Avatar for broj1
0
180
Member Avatar for hwoarang69

Try it this way (escaping double quotes for javascript arguments): <?php echo" <button type='submit' onmousedown='func(\"$item_id_g\");'>test</button> "; ?> or this way (escaping double quotes for html attributes): <?php echo" <button type=\"submit\" onmousedown=\"func('$item_id_g');\">test</button> "; ?>

Member Avatar for broj1
0
119
Member Avatar for Venter

You have some errors in your code: - missing $ character at variable names for $i, $qid - if qid is not a variable but rather an associative index it should be always enclosed within quotes - the name of the $_SESSION array is misspelled (it is not $_SEESION) The …

Member Avatar for broj1
0
2K
Member Avatar for JokerTime

Do not despair, I am here to help you out :-) I hope you have corrected the code according to the post by pzuurveen above. Now, what are the action and method attributes of your form? Depending on that you will either check for existence of $_GET / $_POST array …

Member Avatar for broj1
0
204
Member Avatar for gurlzlubme

LastMitch, how come you dug up all these 7 years old threads all of a sudden :-) It is actually nice that someone cares to offer help to all the forgotten questions but I think this old stuff should be somehow marked as dead by admins.

Member Avatar for broj1
0
250
Member Avatar for classss

If you use mysql, see http://php.net/manual/en/mysqli.construct.php. You might want to think about using a conectivity layer that enables you to change backend. The example is MDB2 fro PEAR framework. See http://pear.php.net/package/MDB2/

Member Avatar for broj1
0
53
Member Avatar for hwoarang69

> it does print eg 2012-12-09 03:34:25. but i cant seem to store in database What is the format of the field you want to store the value into? > You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the …

Member Avatar for urtrivedi
0
228
Member Avatar for mpc123

The double quotes are causing trouble since everything betwen the opening and the closing double quote is a string (array elements do not get parsed correctly and also no concatenation takes place). You can do it the way gavinflud suggested. On the other hand if you wish to use double …

Member Avatar for broj1
0
117
Member Avatar for MiketheBook

> I don't even know what PHP is If you are not kidding :-): PHP is a server side scripting language that does a bit of processing before spitting out a html page (with a .php extension). This is how scripting enabled web server can add some logic to the …

Member Avatar for diafol
0
175
Member Avatar for ishFady

Form values get into the $_GET array after submitting the form. So you first check for the value if it exists: if(isset($_GET['test']) { $y=$_GET['test']; } or you might want to check whether the form has been submitted: if(isset($_GET['submit']) && isset($_GET['test']) { $y=$_GET['test']; }

Member Avatar for Bob Hensley
0
199
Member Avatar for sultankhan

The textarea that is used for commenting should have a name attribute that has image ID in it (say image ID is 6, textarea name is comm-6). Then when you check for submition get the ID from the textarea name, something like: if(isset($_POST['submit'])) { // loopthrough $_POSTarray and search for …

Member Avatar for broj1
0
170
Member Avatar for bbjybon89

Or you can do it in one query (provided that $_POST['checkbox'] contains IDs to delete): // if delete was clicked and some checkboxes were checked if( isset($_POST['delete']) && isset($_POST['checkbox']) && !empty($_POST['checkbox']) ){ // string of IDs to be deleted (separated by ,) $id_list = implode(',', $_POST['checkbox']); $sql = "DELETE FROM …

Member Avatar for broj1
0
207
Member Avatar for cussel

foreach ($data1 as $in1 => $h1) { // temporary array for inner loop, needed for sorting $count_arr_temp = array(); foreach ($data2 as $in2 => $h2) { $match = array_unique(array_intersect($h1, $h2)); // put count data in a temporary array $count_arr_temp[] = count($match); } // sort temporary array rsort($count_arr_temp); // didplay sorted …

Member Avatar for broj1
0
333
Member Avatar for eyeda

Other way of checking it is placing this code on line 34: die("UPDATE staff SET enabled='$status',name='$name', password='$password', email='$email' , department='$department' WHERE id='$id'"); which will echo your query and halt the sript. Now you can examine the query and/or test it in phpmyadmin.

Member Avatar for eyeda
0
1K
Member Avatar for Tinnin

Your code seems to be allright. There are two things that come to my mind. First one is to check whether the first block of the `if` executes at all since maybe you are doing too little of checking of the $_POST values - namely you are not checking for …

Member Avatar for Tinnin
0
144
Member Avatar for nnehadixit

Variable names can not contain spaces. $fmcg application=mysql_real_escape_string($_POST['fmcg application']); Replace spaces with underscores ($fmcg application -> $fmcg_application)

Member Avatar for nnehadixit
0
308
Member Avatar for tcampbell011

Change the function this way: function display(){ return $this->teamName; } You need to refer to the object->property; `this` refers to the current object.

Member Avatar for Squidge
0
228
Member Avatar for Meth0d

Are you sure that you will get better user experience this way? If you let users delete each post without asking them for confirmation first thea are at risk deleting too many posts to quickly. If you ask them for consfirmation at each post they wish to delete you will …

Member Avatar for broj1
0
222
Member Avatar for ello

There are many tutorials out there but they might vary in completeness since they often omit some parts to emphasizes others. But your question is spot on. If I got it right you are asking about what to do with the posted values to use them securely. The trim is …

Member Avatar for ello
0
206
Member Avatar for codingweb

The thing is that you have name attributes for your hidden fields the same for every row so the $_POST array contains only teh last row (last assigned name attributes). You should give the name attributes in each row a unique identifier that is linked to the row in a …

Member Avatar for diafol
0
82
Member Avatar for vizz

Do you have a primary key or unique field in the table and what type it is? This is cruical for some control of which record to access.

Member Avatar for broj1
0
385
Member Avatar for dannybarh

This is a bit strange. You populate the select element with numbers from vehicle_info table and then store the chosen number into the same table. You should have a source for the select element somewhere else (maybe some other table) otherwise you keep running in circles. Or have I missunderstood …

Member Avatar for dannybarh
0
134
Member Avatar for eNnilla

use mysql_real_escape_string() function to escape characters in all input fields. Not just to enable people to enter quotes but also to prevent evil people to enter harmfull code. $title = mysql_real_escape_string($_POST['title']); $content = mysql_real_escape_string($_POST['content']); $creator = mysql_real_escape_string($_POST['creator']); Mind you the connection to mysql has to be established in order to …

Member Avatar for broj1
0
307
Member Avatar for Riu 2009

It is a lot of code to have a look at and a lot of includes which makes it very difficult to test. Also the structure of tables is not shown. And even if it were it is quite a project for someone to help here. In principle I would …

Member Avatar for broj1
0
4K
Member Avatar for jackbauer24-2

In a nutshell: // connect to a database (mysql in this example, using mysqli extension) $link = mysqli_connect('localhost', 'my_user', 'my_password', 'my_db'); // check connection if (mysqli_connect_errno()) { die("Connect failed: " . mysqli_connect_error()); } // a query for selecting age $query = 'SELECT Age FROM tablename WHERE condition=something'; // run the …

Member Avatar for jackbauer24-2
0
261
Member Avatar for Riu 2009

Assuming that id is an integer and autoincremented by the DB then the id fields probably increase with every new question and you can use this approach: Whenever you read and display the question save the id in the session. If there is no id in the session you are …

Member Avatar for broj1
0
4K
Member Avatar for hafiz.muhammadakas

You have probably sent some HTML output before session_start() line in your code. Make sure that the session_start() function is on the very beginning of the script. Also make sure there is no space that you are unaware of in the beginning before the <?php ?> block. If there are …

Member Avatar for gabrielcastillo
0
152
Member Avatar for Noth

First check in your generated html code whether checkboxes have intended names (chkDel[] and values (the ID of the customer). You can do that by looking at the source in your browser (right button and `View Page Source` in Firefox). Then check whether the $_POST contains appropriate values in code …

Member Avatar for broj1
0
157
Member Avatar for rosstafarian

Give each textbox a name that has and ID of the record in it (hopefully you have a primary key in the table, you can use it for this purpose). If you have any code yet I can show you what I mean. Or if I put it in a …

Member Avatar for rosstafarian
0
1K
Member Avatar for freakvista

if(isset($_POST['formImage']) && !empty($_POST['formImage'])) { // do what you like with it }

Member Avatar for broj1
0
161
Member Avatar for spowel4

Use [is_numeric](http://php.net/manual/en/function.is-numeric.php) function. if(is_numeric($string)) { $float = (float) $string; }

Member Avatar for spowel4
0
233
Member Avatar for kaizokupuffball

My opinion: making your own database class might be worth only if you are doing it in order to learn about database handling and OOP. If you need a good and verstaile db class there are many arround which have been developed by dedicated people/teams and through considerable amount of …

Member Avatar for broj1
0
194
Member Avatar for wastedkill

How do you track if user is logged in? It would help if you posted some code. Usually users are tracked in session array so if you use this method, check the values there. something like: // start the session (on the very top of the script) session_start(); // if …

Member Avatar for wastedkill
0
156
Member Avatar for scaiferw

What has the action attribute of your form been set to? If form posts to the same page (#) then set the action to the page name without the querystring, something like: $action = parse_url(__FILE__, PHP_URL_PATH); echo "<form action='$action'>"; ...

Member Avatar for scaiferw
0
670
Member Avatar for dhadha

A quick debugging technique is to check the contents of variables at various stages using a combination of echo, die() and print_r() functions: $sql = mysql_query("SELECT * FROM teachersubject WHERE teacherID ='$id'"); while($test = mysql_fetch_array($sql)) { // inspect the contents of returned row echo(print_r($test, 1)) . '<br />'; $subjectid=$test['subjectID']; // …

Member Avatar for simplypixie
0
155
Member Avatar for double_cola

I would do it simple way without regular expressions which are not very efficient: $allowed = array('Indiana', 'Ohio'); if(!in_array(allowed)) { $errors .= "You have entered the wrong state."; }

Member Avatar for double_cola
0
189

The End.