mikosiko
Members-
Posts
1,327 -
Joined
-
Last visited
-
Days Won
1
Everything posted by mikosiko
-
Delete album and items related to the album HELP
mikosiko replied to Lisa23's topic in PHP Coding Help
Lisa... you have to stick with one version and try to find the problem...posting 2 codes don't help to the people trying to help you... so... change this line echo "<p align=center>Album $row['album_name'] deleted.</p>"; echo "<p align=center>Album {$row['album_name']} deleted.</p>"; if that doesn't fix the problem look for unmatched { or ) or missing ; -
Delete album and items related to the album HELP
mikosiko replied to Lisa23's topic in PHP Coding Help
ok... never mind. try this code or starting from litebearer posted adjust yours <?php error_reporting(E_ALL); ini_set("display_errors", 1); define('ROOT_DIR', './'); define('PROPER', TRUE); define("GALLERY_IMG_DIR", "./photos/"); /** * include common files */ include_once(ROOT_DIR. 'includes/common.inc.php'); // No album id has been selected if (isset($_GET['albums'])) { // get the image file name so we // can delete it from the server $sql = "SELECT album_id, album_name, album_owner, sub_album FROM albums WHERE album_id = {$_GET['albums']}"; $result = mysql_query($sql) or die('Album Selection failed. ' . mysql_error()); if (mysql_num_rows($result) == 1) { $row = mysql_fetch_assoc($result); // get the image filenames first so we can delete them // from the server $psql = "SELECT photo_id, photo_proper FROM photos WHERE album_id = {$row['album_id']}"; $presult = mysql_query($psql) or die('Photo Selection failed. ' . mysql_error()); while ($prow = mysql_fetch_assoc($presult)) { // remove the image and the thumbnail from the server unlink(GALLERY_IMG_DIR . $prow['photo_proper']); unlink(GALLERY_IMG_DIR . 'thumbs/' . $prow['photo_proper']); } // and Now we remove the database entries $sql = "DELETE FROM photos WHERE album_id = {$row['album_id']}"; mysql_query($sql) or die('Delete of Album associated photos failed. ' . mysql_error()); $sql = "DELETE FROM album WHERE album_id = {$row['album_id']}"; mysql_query($sql) or die('Delete album failed. ' . mysql_error()); // album deleted successfully, let the user know about it echo "<p align=center>Album $row['album_name'] deleted.</p>"; } else { echo "<p align=center>Cannot delete a non-existent album.</p>"; } } ?> -
Delete album and items related to the album HELP
mikosiko replied to Lisa23's topic in PHP Coding Help
Lisa... are you using MyIsam or Innodb storage engine for those tables? If you are using Innodb (the default is MyIsam) is not need to implement the code to do cascade deletes because those can be implemented directly in the table(s) definition using FOREIGN KEY and ON DELETE CASCADE constrains. In that way you code should only delete the record(s) in the parent table (and control for possible errors). Maybe this is something that you should look at if you want to learn other alternative. -
try this SELECT a.*, (SELECT MAX(b.ID) FROM web_messages b WHERE b.ID = a.ID) AS Mid FROM web_users a
-
and I have this in my favorites (in case that you could use some ideas) http://explainextended.com/2009/03/17/hierarchical-queries-in-mysql/
-
this should help http://dev.mysql.com/tech-resources/articles/hierarchical-data.html
-
is called a ternary operator basically is the reduced version of a if... else construction http://php.net/manual/en/language.operators.comparison.php
-
query returning no values, but works in database
mikosiko replied to h20boynz's topic in PHP Coding Help
man ... I'm blind too I didn't see that "i" .... Jezzz -
Problem with language in a php page of my website
mikosiko replied to isabelita's topic in PHP Coding Help
in the line where "SERVICIOS" is the code have this onclick="texto(2)" the function texto() is defined accepting 2 parameters... one is the id and the other is the value of lang... in this case the second parameter has not been passed.... in others part of your code this same call reads onclick="texto(2, 'es') hope this help -
query returning no values, but works in database
mikosiko replied to h20boynz's topic in PHP Coding Help
ok... let start with what you didn't see: $ result = mysqli_query($link, $qry); if you read the manual carefully you should have notice that the format is (being $link optional) $result = mysqli_query($qry, $link); right? now... change that line and add $result = mysqli_query($qry) or die(mysql_error()); now that is assuming that you effectively are connecting to the DB... I will like to see what do you have in your config.php file are DB_HOST, DB_USER, DB_PASSWORD and DB_DATABASE variables?.... if so... why they don't have the $ as prefix? and run that code again -
query returning no values, but works in database
mikosiko replied to h20boynz's topic in PHP Coding Help
$qry="SELECT * FROM members"; $result = mysqli_query($link, $qry); read what the manual say about mysql_query() format here http://php.net/manual/en/function.mysql-query.php and you will found what is wrong also is good to enable error display or control it with die(mysql_error()); at the end of your mysql_query line -
and the Notice line is not giving you a clue? Notice: Use of undefined constant Yes - assumed 'Yes'
-
this work for me: <?php $path = 'C:/TEST/'; foreach (new DirectoryIterator($path) as $fileInfo) { if($fileInfo->isDot()) continue; echo $fileInfo->getFilename() . "<br>\n"; } ?> You should look at RecursiveDirectoryIterator too http://php.net/manual/en/class.recursivedirectoryiterator.php
-
well SELECT a.album_id, COUNT(b.photo_id) As NPhotos FROM photos_album a, JOIN photos_table b ON a.album_id = b.album_id GROUP BY a.album_id maybe?
-
Help me to display enum fields value in form
mikosiko replied to linux1880's topic in PHP Coding Help
EDITED: I was replying the same when I saw this -
And why you want to do that?.... when a simple query counting the records in your photo_table while you are displaying the records from your album should do the job?
-
basic rule violated "Within a stored function or trigger, it is not permitted to modify a table that is already being used (for reading or writing) by the statement that invoked the function or trigger." for your further reading http://dev.mysql.com/doc/refman/5.0/en/stored-program-restrictions.html
-
Help me to display enum fields value in form
mikosiko replied to linux1880's topic in PHP Coding Help
One way: - execute a query to the DB to get the enum field definition... per example: $query = "SHOW columns FROM yourtable LIKE 'yourenumcolname'"; $result = mysql_query($query) or die(mysql_error()); $row = mysql_fetch_assoc($result); $thevalues = $row['Type']; echo $thevalues; // here instead of echo you must parse it to obtain the values individually // rest of your code -
could you share the solution in your case?
-
this should work (tested in my side): <?php error_reporting(E_ALL); ini_set("display_errors", 1); $dbname = "your-dbname"; $dbhost = "yourhost"; $dbuser = "youruser"; $dbpass = "thepassword"; $thetable = "here the table name"; $link = mysql_connect($dbhost, $dbuser, $dbpass) or die(mysql_error()); mysql_select_db($dbname) or die(mysql_error()); $result = mysql_query("DESCRIBE $thetable"); while($row = mysql_fetch_array($result)) { echo "{$row['Field']} - {$row['Type']} - {$row['Null']} - {$row['Key']} - {$row['Default']} - {$row['Extra']}<br />"; } mysql_close($link); ?>
-
coincidence !!... I've been working in the same problem/behavior with a testing code for more than 1 hour and I've been having exactly the same issue... output from exec(), shell_exec(), passthru() are truncated. Test machine is WXP with Apache/PHP/MYSQL ... weird..
-
Never used this in the scenario of a remote server/local server... bu according to the Mysql Manual maybe this is an option to explore
-
holly C#$$#$ .... I knew my brain was fried this morning... but never at that extent!!! :'( to the OP.... my apologizes... the code that I posted is a real piece of poopo!! I'm going to kick my but 100 times now.
-
The answer is simple... go back to the first code that you posted and take a look here http://php.net/manual/en/function.mysql-query.php and read carefully the part about "Return Values".... the answer will came up to you clear as water.... fresh water.
-
For what it worth.... I just run this example in my side without any problem at all... maybe it can help you. <?php error_reporting(E_ALL); ini_set("display_errors", 1); $mysqli = new mysqli('localhost','myuser','mypass', 'mydb') or die($mysqli->connect_error()); $database_query = <<<QUERY CREATE TABLE d2b_users ( id INT NOT NULL AUTO_INCREMENT, otro INT NOT NULL, UNIQUE KEY(id) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; CREATE TABLE d2b_statistics ( id INT NOT NULL, xx INT NOT NULL, UNIQUE KEY(id) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; CREATE TRIGGER d2b_auto_statistics AFTER INSERT ON d2b_users FOR EACH ROW BEGIN INSERT INTO d2b_statistics SET id = NEW.id; END; QUERY; $mysqli->multi_query($database_query) or die($mysqli->error()); $mysqli->close(); ?>