-
Posts
24,563 -
Joined
-
Last visited
-
Days Won
822
Everything posted by Barand
-
Function to sort multidimensional array by a value
Barand replied to doddsey_65's topic in PHP Coding Help
the function should be function sort_by_value($x, $y) { return ($x['value'] - $y['value']); } a sort function needs to return -, 0 or + values -
Is this what you are trying to do? mysql_query("INSERT INTO ".$school_id."_outbox (senderno, destno, message, student_id) SELECT '$senderno', p1contact, '$message', '$student_id' FROM 1_contacts");
-
here you are $str = date('dmY'); do { $str = (string)array_sum(str_split($str)); } while (strlen($str) > 1); $bgc = '#'. str_repeat($str,6); echo $bgc;
-
What does echo $q give. If $_SESSION['numbers'] is empty then the query will look like ... NOT IN () ... so try if(!isset($_SESSION['numbers'])){ $_SESSION['numbers'] = array(0); } so you get ... NOT IN (0) ... and avoid a syntax error
-
Then you are either finding no match or more than 1 match. Always put the query string into a variable so you can echo it if required. $sql = "SELECT foo FROM bar"; $result = mysql_query($sql); In cases like this you can now echo $sql then copy and paste the actual query into phpMyAdmin (or similar) and see what the results are
-
One approach might be to write some demo sites/applications for prospective clients to try. This would give you a portfolio and build up your experience. But do finish them.
-
Then fix it. You are either referencing a non-existent column or you have a string value in your query containing "test1" that is not inside quotes. We haven't even seen the query, let alone your table structures, so your pretty much on your own, unless we have a psychic in or midst.
-
Have you got error reporting on? Have you you checked what mysql_error() returns after running the query?
-
see what mysql_error() returns after executing the query. also echo($q) to see what was executed
-
Just because query returns no results does not mean it isn't working. It just means it didn't find any rows that match the WHERE criteria
-
Use mysql_num_rows($query) to see if any rows were found
-
Don't worry, mysql will allocate a unique insert id to each connection
- 1 reply
-
- phpmysql
- transactions
-
(and 2 more)
Tagged with:
-
Your inputs need name attributes. It is the name and value that is passed in the post (not the id and value)
-
Already told him that:
-
alternative method $db = new mysqli(HOST, USERNAME, PASSWORD, 'metrocellars'); $sql = "SELECT l.location , r.region , w.winery_name , w.url , p.label FROM location l INNER JOIN region r USING (lid) INNER JOIN product p USING (rid) INNER JOIN winery w USING (pid) INNER JOIN varietal v USING (vid) WHERE lid = 2 ORDER BY r.region, w.winery_name, v.varietal "; $prevRegion = $prevWinery = ''; $res = $db->query($sql); while (list($loc,$rgn, $wnry, $url, $label) = $res->fetch_row()) { if ($prevRegion != $rgn) { echo "<h3>$rgn</h3>\n"; $prevRegion = $rgn; $prevWinery = ''; } if ($prevWinery != $wnry) { echo "<a href='$url'>$wnry</a><br>\n"; $prevWinery = $wnry; } echo "<span style='margin-left:15px;'>$label</span><br>\n"; }
-
`word` = 'a' OR `word` = 'b' OR `word` = 'c' OR `word` = 'ab' OR `word` = 'ac' OR `word` = 'ba' OR `word` = 'ca' OR `word` = 'cb' OR `word` = 'abc' OR `word` = 'cba' OR `word` = 'bca' */ can be simplified to `word` IN ('a', 'b', 'c', 'ab', 'ac', 'ba', 'ca', 'cb', 'abc', 'cba', 'bca')
-
$to is given a value early on in the code only if certain conditions are true. I you later try to output when those conditions are not true then it will be undefined.
-
You need to escape $img_src as it contains quotes. mysql_real_escape_string
-
I have just told you the solution
-
that only proves that the string value "../backend/playlist_form.php" exists
-
put $img_src in single quotes, not backticks. (Backticks say "this is a column name")
-
realpath will just return false if the path/file does not exist
-
Don't assign the $result['isProcessed'] back to $result. $processed = $result['isProcessed'] ? 'yes' : 'n/a'; echo "<td>$processed</td>";
-
Where to store sensitive client details (MYSQL DB credentials)
Barand replied to Neji's topic in PHP Coding Help
According to the MySQL manual: Note The PASSWORD() function is used by the authentication system in MySQL Server; you should not use it in your own applications. For that purpose, consider MD5() or SHA1() instead. Also see RFC 2195, section 2 (Challenge-Response Authentication Mechanism (CRAM)), for more information about handling passwords and authentication securely in your applications. -
I had a look at your elso1.php output and I'm puzzled why the column headings are out of sequence. Did you use the latest version I posted that has the natsort() included?