premiso
Members-
Posts
6,951 -
Joined
-
Last visited
-
Days Won
2
Everything posted by premiso
-
Databases were made for large amounts of data. To optimize it, you should index only rows you will query. If you plan on having a search you should look into Full Text searching or another searching type option such as Sphynx. But splitting the data into two separate tables should not be done as you would have to query the second table as well and there in you now have two queries you have to run and it will tax the database just the same, if not harder.
-
$text = 'datetime_system=>2010-10-14 02:07:07{~-SePaRaT0R-~}username_system=>test (16){~-SePaRaT0R-~}ip_system=>79.354.76.127'; preg_match('~.*username_system=>.* \(([0-9]+)\).*~i', $text, $matches); echo $matches[1]; Should do what you are looking for.
-
Why do you feel the need to separate the product description from the other table?
-
The first thing that pops into my mind is what columns are queried and are they indexed? If not, I would index the columns that the database is queried on (excluding the Primary Key as that is indexed by default). You should not need to separate them out into different tables.
-
Why not just do a preg_replace to replace the first 5 words?
-
Set the session cookie to expire after 15 minutes, given that you are using sessions to keep track if someone is logged in or not.
-
Tutorial for creating a 'search engine' with multiple word search
premiso replied to defroster's topic in PHP Coding Help
Give this one a shot: http://www.slunked.com/blog/php-mysql/2010/01/simple-sql-search-using-php-mysql -
Why are you using array_push? I do not think it is relevant for your scenario: while($row=mysql_fetch_array($result)) { $data[$row['selected_address']] = $row['security_code']; $cant++; } Is what I think you are looking to do.
-
Of course, you just have to look up the structure of it.
-
Multipart form won't post when multiple type=input elements are defined
premiso replied to buddy's topic in PHP Coding Help
Chances are you have reached the POST and or UPLOAD limits set in the php.ini Take a look at these variables in your php.ini: post_max_size = 8M upload_max_filesize = 2M max_file_uploads = 20 The M means megabytes. Change that to a suitable number for what you think an upper limit should be on the items you want to upload. Also check the file uploads, make sure it is > 2 -
Well, if that is the case, I would use foreach: unset($array[1]); foreach ($array as $parent) { foreach ($parent as $child) { echo $child . '<br>'; } } Should give you your desired output.
-
This is what happens when you do not look at the line the error refers to. Indeed, you only set $fang_spotted when the form has been POST'ed and you try to use that variable no matter if the form was POST'ed or not, so the initial load will throw that error. To fix it: Yes <input id="fang_spotted" name="fang_spotted" type="radio" value="yes" <?php echo (!empty($fang_spotted) && $fang_spotted == 'yes') ? 'checked="checked"' : ''); ?> /> No <input id="fang_spotted" name="fang_spotted" type="radio" value="no" <?php echo (empty($fang_spotted) || $fang_spotted != 'yes') ? 'checked="checked"' : ''; ?> /><br /> That will test the variable to make sure that it is indeed populated and avoid errors for the initial page load.
-
Honestly, I think all you need to use is the sort method: $array[0][0] = "aaa"; $array[0][1] = "111"; $array[1][0] = "bbb"; $array[1][1] = "222"; $array[2][0] = "ccc"; $array[2][1] = "333"; $array[3][0] = "ddd"; $array[3][1] = "444"; unset($array[1]); sort($array); $numrecs = count($array); for ($x=0; $x<$numrecs; $x++) { echo $array[$x][0] ."<br>"; echo $array[$x][1] ."<br>"; } Should do what you want.
-
The reason is if the box is not checked, it does not get passed as a parameter to POST. $fang_spotted = !empty($_POST['fang_spotted'])?mysqli_real_escape_string($dbc, trim($_POST['fang_spotted'])):'no'; That should default the value to no if fang_spotted is not being passed to the POST data. This, may however be a flaw in your form code. As if one or the other should be checked, well that error should not occur. EDIT And indeed I did find the issue in your code: Yes <input id="fang_spotted" name="fang_spotted" type="radio" value="yes" <?php echo ($fang_spotted == 'yes' ? 'checked="checked"' : ''); ?> You never close that input statement. Change it to: Yes <input id="fang_spotted" name="fang_spotted" type="radio" value="yes" <?php echo ($fang_spotted == 'yes' ? 'checked="checked"' : ''); ?> /> And see if it works properly.
-
You will want to look into curl which will help you fetch the data and then to parse it I would look into the DOM.
-
Can you post the desired array outline? Like what you want it to end up being.
-
//aller chercher le numéro de l'id de l'usager $IDmembre = mysqli_query($connection, "SELECT id_membre FROM membres WHERE username = '$user'"); $IDmembre = mysqi_fetch_row($connection, $IDMembre); $IDmembre = $IDmembre[0]; $IDgroupes = mysqli_query($connection, "SELECT id_groupe FROM membres_groupe WHERE id_membre = '$IDmembre'"); You needed to fetch the column that you wanted to use in the next query, above is a rough example of what I am talking about.
-
Multiple Select Statement? Or am I missing something?
premiso replied to Bricktop's topic in MySQL Help
I try...sometimes > -
Multiple Select Statement? Or am I missing something?
premiso replied to Bricktop's topic in MySQL Help
I think you will have to do multiple queries for each section, you can do this all in one go if you like using UNION ALL: (SELECT * FROM news WHERE category = 'World News' LIMIT 3) UNION ALL (SELECT * FROM news WHERE category = 'Local News' LIMIT 3) And if you want it to be dynamic: $result = mysql_query("SELECT category FROM news GROUP BY category") or trigger_error("Error fetching the categories: " . mysql_error()); if ($result) { $newsQuery = array(); while ($row = mysql_fetch_assoc($result)) { $newsQuery[] = "(SELECT * FROM news WHERE category = '" . $row['category'] . "' LIMIT 3)"; } $newsQuery = implode(' UNION ALL ', $newsQuery); // glue it back together $result = mysql_query($newsQuery) or trigger_error("News query failed with error: " . mysql_error()); $prevCat = ''; $display = ''; while ($row = mysql_fetch_assoc($result)) { if ($prevCat != $row['category']) { $display .= $row['category'] . '<br>'; $prevCat = $row['category']; } $display .= $row['title'] . '<br>'; // change title to whatever it should be } }else { $display = 'Failed fetching categories.'; } echo $display; Should get you the desired display. I just roughed this together so may be some minor issues, if you cannot work them out let me know and I will help you out. -
switch ($_GET['page']) { case 'news': echo ("NEWS HERE"); $id2 = "extra id"; break; case 'schedule'; echo ("SCHEDULE HERE"); break; default: echo ("MAIN PAGE HERE"); break; } You had some syntax issues there, removed the extra } from it. Also showed how / where you would put the second "id". If you need a better example, you need to provide us with more thorough information and examples.
-
Reading between the lines, you need to tell us "WHAT" isn't working and any possible errors, and what you have tried to get it working. No one is going to blindly go through all that code to find your mistake.
-
$string = "word word word"; $array = explode(" ", $string); $display = ""; foreach ($array as $word) { $display .= '<a href="' . $word . '">' . $word . '</a>'; } echo $display; Should do it for ya.
-
Problem with mail() and string with "unique" URL
premiso replied to jrbush82's topic in PHP Coding Help
Nice, thanks for responding back with the answer. -
Problem with mail() and string with "unique" URL
premiso replied to jrbush82's topic in PHP Coding Help
I doubt you will be able to fix this as it is really up to how the users Email Application handles URLs. You can try making it a hyperlink using the anchor HTML Tag, which some email applications will allow (along with the plain text link). But other then that there is nothing you can do.