-
Posts
3,404 -
Joined
-
Last visited
-
Days Won
55
Everything posted by Ch0cu3r
-
What is the output of print_r for $upper_split and $p2 It is probably array_combine that is the issue not foreach. However to answer your quest the alternative to foreach would be while loop with each() (see Example #2) or a for loop
-
How to sum up the total and reflect it as a link.
Ch0cu3r replied to heroisback's topic in PHP Coding Help
freelance forum then -
Right back on topic. Sorry MoFish for confusion. Not quite correct. Change it to public function get_all_league() { $db = new sql(); $sql = "SELECT * FROM $this->tablename"; $db->query($sql); $section_object = new section_object(); if(mysql_num_rows()){ while($k = $db->fetch_array($db)) { $total[] = $k; } } return $total; } However it would be better to add mysql_num_rows() to a method in your sql class instead, example public function num_rows() { return mysql_num_rows(); } Instead of doing if(mysql_num_rows()){ you'd use if($db->num_rows()) instead.
-
@objnoob are you reading/replying to the right thread?
-
That would be the case if MoFish is using mysqli object. The mysql_*() is procedural code only
-
What? Where is the limit here $sql = "SELECT * FROM $this->tablename"; How else are you supposed to check if the query returned anything.
-
This is because you call $db->fetch_array(); before the while loop. Each time you call this it'll return a row from the query. Basically yourare losing a result for checking if the query returned anything. What you should be doing is use mysqli_num_rows (<-- mysqli) or mysql_num_rows (mysql) to check for this.
-
No. You should name them as item[] and description[] This will make the $_POST['item'] and $_POST['description'] values to be submitted as an array. You just got to simply loop through this array to get the values.
-
Loading.gif image when pressing upload file button
Ch0cu3r replied to mikkel809h's topic in PHP Coding Help
Not possible, unless you are performing the file upload using AJAX. -
What are you expecting? What foreach?
-
How to sum up the total and reflect it as a link.
Ch0cu3r replied to heroisback's topic in PHP Coding Help
What code have you tried? Or you wanting someone to code this for you? -
Any reason you run your server on port 82. The standard port for HTTP servers is port 80. If your server is not running on port 80 then you need to define the port in the url. Why cant you use port in actionscript?
-
Remove the // from in front of mysql_connect The // is a comment, you are causing the connection to be ignored.
-
Having separate templates will allow for easier edits, for example if your want to change how your header/footer/sidebar looks you only need to edit one file. If you didn't separate your view components then you will need to edit every single template. Do note that codeignitor is dead and is no longer being worked on. I think the trend now is Laravel 4.
-
How do I pull in different includes with a list of links?
Ch0cu3r replied to c_martini's topic in PHP Coding Help
@dalecosp Wouldn't an absolute filepath be better? Like this http://forums.phpfreaks.com/topic/282511-is-it-dangerous-to/?p=1451616 -
Try passing fn and ln to encodeURIComponent() . var vars = "firstname="+encodeURIComponent(fn)+"&lastname="+encodeURIComponent(ln); The vars is constructing a url and the & has a spacial meaning. Its the argument separator for the query strings. encodeURIComponent will encode & so it will be handled safely.
-
Mod rewrite does not change your urls. It allows you to map fake urls to real ones. You need to change the links in your code so it outouts link in the format that you set your rewriterule to. So change your code (from the old url) <a href="space1.php?name=<?php echo $result['name']; ?>"><?php echo $result['name']; ?></a> to (the new url) <a href="/<?php echo $result['name']; ?>"><?php echo $result['name']; ?></a> The will output urls like site.com/name The site.com/name url will match the url for the rewriterule, and so when this type of url is request mod_rwrite will actually call site.com/space1.php?name=name
-
How are you checking the output of the PHP code? If you are outputting text within <script></script> tags then you wont see it in the browser. You need to right click view source to see the javascript code. Also note. PHP code is executed on the server. So anything within the <script></script> tags will be treated as javascript, not as PHP! Also when posting code in the forum please press the code button ( the <> button). This will make your posts more clearer.
-
Your database connection is failing. Checking that PHP is connecting to MySQL properly when your call mysql_connect(). Use mysql_error() to see why PHP is failing to connect to mysql.
-
Move this code $sql = sprintf("SELECT COUNT(*) as total FROM tbl_club_contacts WHERE companyname = '%s' ", $db->real_escape_string($companyname)); $result = $db->query($sql); $row = $result->fetch_assoc(); if ($row['total'] > 0) { $errors['companyname'] = "The name '$companyname' already exists."; } So it is after this else { $companyname = test_input($_POST["companyname"]); }
-
Note by default XAMPP doesn't come with a password for the root user. You need edit your scripts config and remove the password for connecting to mysql.
-
Change $db to $con on line 55. Also the code Barand gave you here was an example for checking the word 'the' was at the start of the string. You need to adapt it to check the value in $_POST["companyname"]. It is not meant for a simple copy and paste solution.
-
No this is not the case. PHP does not go back on itself. The solution is to perform a header redirect as soon as the record has been updated. This will clear all $_POST data and thus should then display the record listings.
-
The problem the action is required for updating the record. This action is being reinforced when the Edit Record form is submitted. This is why the edit form is displayed. What you need to do is perform a header redirect when the record has been updated header('Location: pagename.php');