812 Posted Topics

Member Avatar for geneh23

Your function is not returning the number of comments but the resource (a special PHP type) for the query. And also the query has to be changed to: $sql = "SELECT COUNT(*) FROM `comments` WHERE `post_id`= {$pid}"; The function should be something like: function gather_comments ($pid){ $pid = (int)$pid; $sql …

Member Avatar for geneh23
0
459
Member Avatar for bradly.spicer

Line 22: mysqli_fetch_assoc($ChangeDownloadSQL){ You should terminate it with ;

Member Avatar for bradly.spicer
0
142
Member Avatar for ankitamalu

It would help if you posted the code you already have and table structures so we can build from there. Basicaly what you do is: 1. read the database to get the list of countries 2. build the first drop down (html select element ) with options containing countries 3. …

Member Avatar for diafol
0
368
Member Avatar for bfitzgerald

The form data is being sent to the database only when you execute a query. So after collecting the data first check the dates and only if within the range, connect to the database and execute the query. if($sDate < $enDate && $sDate > $exDate) { // connect to the …

Member Avatar for bfitzgerald
0
203
Member Avatar for pranavsai3

There seem to be no syntax errors but this does not guarantee your code works. So make sure you have your php.ini set to display errors and post the errors that you get. Other tips: * Use meaningful names for variables; `$x`, `$y` etc do not tell much but are …

Member Avatar for broj1
0
135
Member Avatar for riahc3

$_COOKIE is associative array. If you want to turn it to numerically indexed you can use [array_values()](http://php.net/manual/en/function.array-values.php) function. But you are loosing valuable information. You can list values this way: foreach($_COOKIE as $value) { echo $value; }

Member Avatar for diafol
0
154
Member Avatar for jethaya

The `<textarea>` tag should be be ended with `</textarea>` end tag. Anything between these two tags gets displayed, but as a plain text. I believe the html code (the table in your case) will be displayed just as plain text and not formatted as a table.

Member Avatar for jethaya
0
338
Member Avatar for OsaMasw

Have you taken into account the fact that the same visitor will have different session ID on each visit (on each session)?

Member Avatar for OsaMasw
0
3K
Member Avatar for Carpetfizz

I don't see any submit button. How do you submit the form? You can change the hidden input into submit button. Change this code: <input type="hidden" name="submitted" value="true" /> into this code: <input type="submit" name="submitted" value="Submit" />

Member Avatar for diafol
0
184
Member Avatar for Vijaysurya

If you need to know only whether email exists or not, use COUNT(*) in your query and use fetchColumn() to get the number of rows found: foreach($email as $em) { $sql = "SELECT COUNT(*) from sf_guard_user sf,personal pi where pi.user_id = sf.id and sf.email_address = '$em' "; $query = $db->prepare($sql); …

Member Avatar for jkon
0
282
Member Avatar for GlenRogers

You can do multiple insertion with one query: if (isset($_POST['submit'])){ // start the query $query = 'INSERT INTO links VALUES '; // get number of elements in the array containing links $linksCount = count($_POST['alink']); // step through the array containing links for($i = 0; $i < $linksCount; $i++) { // …

Member Avatar for GlenRogers
0
328
Member Avatar for Kmhnz201

I am not sure whether I got exactly what you want but I can suggest you use a function that will return the ID formed as a string. Something like: function getCustomID($id) { // check if ID is within the limits (you can go from a01 to z99 only) if($id …

Member Avatar for broj1
0
311
Member Avatar for shakayu

Your responsibility is to format the data read from the database, using PHP and HTML, into something that looks useful and appealing to the user. You can use tables, lists and other HTML elements and CSS. Regarding CSS you can use [media rules](http://www.w3schools.com/css/css_mediatypes.asp): @screen for onscreen display in the browser …

Member Avatar for broj1
0
183
Member Avatar for yy886

Use a rich text editor. I use [TinyMCE](http://www.tinymce.com/) and it is one of the best in my opinion. But you have to be aware that there is some learning curve.

Member Avatar for broj1
0
2K
Member Avatar for dhani09

You first have to insert new user data into tbl_user table, somehow creating fields (id could be autoincrement). Then use this user ID and add it to the query for the tbl_userprofile table.

Member Avatar for dhani09
0
218
Member Avatar for sigvewinter

On line 12 you assign a filename to $filename variable: $filename = stripslashes($_FILES['file']['name']); which is good. But then you do not use that variable on line 62: $filename = "../../../../../../../../bloggbilder/". $_FILES['file']['name']; which is strange since it defeats the purpose of the code on line 12. I think you should create …

Member Avatar for broj1
0
1K
Member Avatar for davy_yg

What do you mean by offline? Are database and webserver accessible when you are offline (localhost) or are they somewhere else (accessible through internet)? Do you have php.ini set up to display errors? Do you have a ob_end_flush() command at the end?

Member Avatar for TonyG_cyprus
0
244
Member Avatar for ibn_sumal

As AHarrisGsy says you did not assign values from $_POST to variables you use in your query. So check for the existence of each of $_POST element, escape the values and assign them to variables. If any of the $_POST elements is missing then display an error message. if(isset($_POST['warranty']) && …

Member Avatar for ibn_sumal
0
423
Member Avatar for akkbkht

To add a row at the end of the HTML table you can use Javascript and insertRow() and insertCell() methods. Create a function that will insert a row and four cells in that new row. Then make a link with an onclick event that will trigger inserting of the row. …

Member Avatar for akkbkht
0
10K
Member Avatar for sumon_ahona

On line 22 you are missing a semicolon on the end of the statement. In the query all the field names should be enclosed in backticks and not in single quotes (a mysql syntax requirement).

Member Avatar for broj1
0
184
Member Avatar for yap.junjie.7

You are missing a semicolon at the end of line 5, hence the T_IF error (if statement is not expected there if no semicolon): session_start() Same on line 17: mysql_error($handle)

Member Avatar for TonyG_cyprus
0
396
Member Avatar for Venter

In PHP code use session_start() on the beginning to use a session. <?php session_start(); if($_POST) { $_SESSION['array']=array(); array_push($_SESSION['array'],($_POST)); print_r($_SESSION['array']); } ?>

Member Avatar for masterjiraya
0
299
Member Avatar for beginnerpals

I tested your code on my server and it works OK. Clicking on Back button always brings me to index.php. Make sure you have no html before the code you posted (not even a space). If you have any html before a header() function, the function will not work.

Member Avatar for imBaCodes
1
12K
Member Avatar for joshl_1995
Member Avatar for sagisgirl

`mysql_num_rows()` function returns a number of found rows (an integer), not an array of rows. You should use a `mysql_fetch_assoc()` in a while loop function instead. Something like: while(mysql_fetch_assoc($rs_k8goodsin)) { echo '<tr>'; echo '<td class="labelcell">' . $count . '</td>'; echo '<td>' . $reck8goodsin['goodsDesc'] . '</td>'; echo '<td>' . $reck8goodsin['k8goodsQty'] . …

Member Avatar for masterjiraya
0
361
Member Avatar for branding4you

The solution for your requirement seems to be OK. But in some circumstances the result in line 5 returns FALSE which indicates an error when querying. You should change the code in line 5 to: $result=mysql_query($statement) or die(mysql_error()); This way if there is an error when querying the error will …

Member Avatar for branding4you
0
224
Member Avatar for abhi10kumar

Also the ultimate checklist for web app security is [[OWASP's to 10]](https://www.owasp.org/index.php/OWASP_Top_Ten_Cheat_Sheet). It is comprehensive but it is worth taking some time to get to grips with it.

Member Avatar for broj1
0
225
Member Avatar for Venter

<?php $name=?> This piece of code will generate an error since it is not complete. To pas a JS function value to PHP the JS function should return the value first. Then the value could either be 1. set into a form element (maybe a hidden input) and the form …

Member Avatar for minitauros
0
262
Member Avatar for Martin C++

public function getLastInsertId() { // you can do checks first (has the query been successful etc) return $this->mysqli->insert_id; } It would be good idea to initialize the properties: protected $mysqli = null; protected $result = null; I would also use more descriptive names. The connection class is not only doing …

Member Avatar for Martin C++
1
155
Member Avatar for missy_mi
Re: Help

First check if your SMTP server is running and is correctly set up.

Member Avatar for broj1
0
247
Member Avatar for kiLLer.zoh_1

Variables $title and $entry haven't been defined anywhere in the script. Did you forget to add these two lines: $title = $_POST['title']; $entry = $_POST['entry'];

Member Avatar for kiLLer.zoh_1
0
199
Member Avatar for aisha.edris1

The problem is probably in this line: $start =mysql_real_escape_string($_POST['start']); $_POST['start'] is set if user selects one of the radio buttons (booking time). If user does not select any button you have to display an error message, but you have to test for it first: if(isset($_POST['start'])) { $start =mysql_real_escape_string($_POST['start']); } else …

Member Avatar for aisha.edris1
0
185
Member Avatar for imaditigarg

As NardCake said put session_start() function on top of the script so you can use a session. Then do not use session_register() function since it has been [deprecated](http://php.net/manual/en/function.session-register.php) and removed after PHP 5.4. Just assign the values to the $_SESSION array (see NardCake's post). Then before using $_POST array values …

Member Avatar for Webville312
0
173
Member Avatar for sagisgirl

I would presume that the query: $query_recTenantuser = "SELECT * FROM md_storage WHERE tenantID='".$tenantID."'"; will return just one row ($tenantID is probably unique), so in the select element (drop down) you will have only one option. That does not make senese. Correct me if I am wrong.

Member Avatar for sagisgirl
0
202
Member Avatar for squeak24

You could add this code somewhere at the end of the snippet above: die('<pre>' . print_r($send_params, 1) . '</pre>'); This will display array of the final version of all parameters needed for sending. Now you can go through each element and check it. Carefuly look at the `$send_params['headers']` if it …

Member Avatar for broj1
0
327
Member Avatar for DaveyMoyes

What is the error message? Does `$_SESSION['clubsId'][0]` have any value? Have you tried to display the query and test it in phpmyadmin: die("SELECT * FROM cards2 WHERE cardid NOT LIKE '{$_SESSION['clubsId'][0]}'"); It is usually a good practice to test for variable values before using them in queries: if(isset($_SESSION['clubsId'][0])) { mysql_query("SELECT …

Member Avatar for DaveyMoyes
0
178
Member Avatar for James singizi

Quote the field names with backtick (assumming that you use mysql): $qry = "insert into users (`name`, `surname`, `email`, `password`, `date`) values ('$name', '$surname', '$email', '$password', '$date')"; This is how you make sure column names do not clash with any keywords. Not sure if this is the right solution for …

Member Avatar for broj1
0
198
Member Avatar for hallianonline

You pass the selected values to modellist.php by ajax for some processing, using `$_POST` array, if I got the code correctly. So the modellist.php script would be good candidate to save values to the session. IN modellist.php just assign the values to the `$_SESSION` array using their names for associative …

Member Avatar for broj1
0
199
Member Avatar for phpDave

You can also insert multiple sets of values in one query: INSERT INTO table_name (column1, column2, column3) VALUES (value1, value2, value3), (value4, value5, value6), (value7, value8, value9)

Member Avatar for phpDave
0
135
Member Avatar for asifalizaman

Also [phpacademy](https://phpacademy.org/) if you prefer watching videos.

Member Avatar for diafol
2
293
Member Avatar for akuteru

Is it only that you do not want to to have a submit button or do you not want to reload the page? In first case you can use onchange event of the select (dropdown). echo '<select name="room" id ="rooms" onChange="this.submit()">'; The form wil get submitted once you select an …

Member Avatar for broj1
0
210
Member Avatar for engrjd91

And info on cookies and session from PHP's point of view: http://php.net/manual/en/features.cookies.php http://www.php.net/manual/en/book.session.php

Member Avatar for engrjd91
0
103
Member Avatar for guilherme.carvalho.9250

You should have defined action attribute in the <form> tag which is the name of the script that will process the data. The script should go something like this: <?php // if submited the value will be in the $_POST['expenses'] element of the $_POST array // (provided that the method …

Member Avatar for broj1
0
9K
Member Avatar for siddiqui_1985

Add a value attribute to each option tag: echo '<option value="' . $rows[1] . '">'.$rows[1].'</option>'; And make sure you enclose the select element in <form> </form> tags?

Member Avatar for broj1
0
5K
Member Avatar for bantex07

You use mysqldump program to export database into a SQL file, something like: mysqldump -u USER -p DATABASE > FILENAME.sql then use mysql client to import SQL file into another database: mysql -u USER -p DATABASE < FILENAME.sql This was taken from [this link](http://www.ghacks.net/2009/12/29/how-to-import-and-export-a-database-in-mysql/). EDIT: I just noticed that you …

Member Avatar for bantex07
0
206
Member Avatar for ismael ahm@d

I think the `$nomineeid => $voted, $p_vote` part in line 10 is not valid syntax. foreach (array_combine($cLists, $Votes, $Votes_p) as $nomineeid => $voted, $p_vote){ The [foreach](http://php.net/manual/en/control-structures.foreach.php) construct is defined as foreach (array_expression as $key => $value) so in your case PHP expects a `)` instead of a `,` after $voted. …

Member Avatar for broj1
0
655
Member Avatar for mathieu89

WHere do you keep the list of URL's? If it is a file or an array then do a while or foreach or for loop reading the urls, getting the value and add values to the insert query: // your URLs (in an array in this example) $url_list = array( …

Member Avatar for broj1
0
4K
Member Avatar for davy_yg
Re: OOP

My opinion: if you develop a complex site start using it soon since it will help you keep your code organized and under control. But it might take some time to learn it and it is probably not a good idea to learn on a real project. Well, I am …

Member Avatar for pritaeas
0
148
Member Avatar for unikorndesigns

Check also your setting for the display_errors directive, as szabizs suggested. If it is set to false (prior to php 5.2.4) the errors won't get displayed.

Member Avatar for broj1
0
290
Member Avatar for Motifaithed

When user clicks on logout link it takes him to the logout script that has the code that Webville312 suggested in his post. The script does not do anything visual. It just destroys the session and redirects to the index page. We are assuming here that you keep the login …

Member Avatar for Motifaithed
0
339

The End.