Jump to content

jigsawsoul

Members
  • Posts

    137
  • Joined

  • Last visited

Everything posted by jigsawsoul

  1. Hi, I'm trying to merge the JSON results of playlists returned from soundcloud.com although I'm having some trouble getting this to display correctly. The results are being displaying nested, where am I going wrong and how can I get this to merge so there is just one array with three sets of data. Check the image of how it is displayed at the moment Any help would be amazing, thanks you in advance <?php $playlists = array( 'https://api.soundcloud.com/playlists/121967270/?&client_id=###', 'https://api.soundcloud.com/playlists/121906753/?&client_id=###', 'https://api.soundcloud.com/playlists/121906816/?&client_id=###' ); $json = array(); foreach ($playlists as $playlist) { $data = json_decode(file_get_contents($playlist)); $json = array_merge(array($json, $data)); } $json = json_encode($json); header('Content-Type: application/json'); echo $json; ?>
  2. Overview: Sort unique string from an array and display results into a variable which can be echoed into jQuery to be displayed as a graph. I using Wordpress with a repeater from custom post fields plugin, code below: $repeater = get_field('treatments'); foreach( $repeater as $key => $row ) { column_id[ $key ] = $row['treatment_name']; } array_multisort( $column_id, SORT_ASC, $repeater ); foreach( $repeater as $row ) { print_r($row); } The print_r returns.. Array ( [treatment_name] => back pain [pain_level] => 4 ) Array ( [treatment_name] => back pain [pain_level] => 5 ) Array ( [treatment_name] => back pain [pain_level] => 7 ) Array ( [treatment_name] => back pain [pain_level] => 10 ) Array ( [treatment_name] => shoulder pain [pain_level] => 3 ) Array ( [treatment_name] => shoulder pain [pain_level] => 8 ) Array ( [treatment_name] => shoulder pain [pain_level] => 10 ) I wish to be able to sort the array data into a variable I can using within JS. { treatment: '1', a: 4, b: 3 }, { treatment: '2', a: 5, b: 8 }, { treatment: '3', a: 7, b: 10 }, { treatment: '4', b: 10 }, A = back pain B = shoulder pain [treatment_name] - is a text field, so I looking for every unique [treatment_name] to added for example having one treatment called 'foot ache' with the pain level of 6 would be added to the start of the list as C. e.g. { treatment: '1', a: 4, b: 3, c: 6 }, { treatment: '2', a: 5, b: 8 }, { treatment: '3', a: 7, b: 10 }, { treatment: '4', b: 10 }, I have gone over and over trying to work the logic out but seems my level of php is not up to par, so I thought no better place to asked then the people who got me this far.. Any questions please do let me know, and anyone will to help your a star..
  3. Great. I don't think error logging is turned on. How would I go about this?
  4. I enabled php and apache which come preinstalled on os x lion and installed phpmyadmin last week to start learning some more on my new mac book pro. Although I am having some trouble with the first stage of the tutorial which I'm following. I'm trying to set my url to rewrite back to the index page. .htaccess file. RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-l RewriteRule ^(.+)$ index.php?url=$1 [QSA,L] When going to the index page I'm able to see the page fine, but when go to (e.g. 'http://localhost/~jigsawsoul/mvc/testingrewrite') which should rewrite to the index page. I get this error message. I'm pretty new to all this I just trying to follow an MVC tutorial here, - but stuck on the first stage Any help would be great thanks guys, I'm a noob
  5. How can I stop this, can I simply remove the word die..?
  6. Contact form works but stop html (footer showing) after the php has run, can't seem to stop this, any help guys and girls... http://jigsawsoulmedia.com/_web/manns/Tours/contact.php <h1>Contact us</h1><br /> <?php if(isset($_POST['email'])) { // CHANGE THE TWO LINES BELOW $email_to = "howse.richard@gmail.com"; $email_subject = "Website Contact Form"; function died($error) { // your error code can go here echo "We are very sorry, but there were error(s) found with the form you submitted. "; echo "These errors appear below.<br /><br />"; echo $error."<br /><br />"; echo "Please go <a href='contact.php' class='backlink'>back</a> and fix these errors.<br /><br />"; die(); } // validation expected data exists if(!isset($_POST['first_name']) || !isset($_POST['last_name']) || !isset($_POST['email']) || !isset($_POST['telephone']) || !isset($_POST['comments'])) { died('We are sorry, but there appears to be a problem with the form you submitted.'); } $first_name = $_POST['first_name']; // required $last_name = $_POST['last_name']; // required $email_from = $_POST['email']; // required $telephone = $_POST['telephone']; // not required $comments = $_POST['comments']; // required $error_message = ""; $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/'; if(!preg_match($email_exp,$email_from)) { $error_message .= 'The Email Address you entered does not appear to be valid.<br />'; } $string_exp = "/^[A-Za-z .'-]+$/"; if(!preg_match($string_exp,$first_name)) { $error_message .= 'The First Name you entered does not appear to be valid.<br />'; } if(!preg_match($string_exp,$last_name)) { $error_message .= 'The Last Name you entered does not appear to be valid.<br />'; } if(strlen($comments) < 2) { $error_message .= 'The Comments you entered do not appear to be valid.<br />'; } if(strlen($error_message) > 0) { died($error_message); } $email_message = "Form details below.\n\n"; function clean_string($string) { $bad = array("content-type","bcc:","to:","cc:","href"); return str_replace($bad,"",$string); } $email_message .= "First Name: ".clean_string($first_name)."\n"; $email_message .= "Last Name: ".clean_string($last_name)."\n"; $email_message .= "Email: ".clean_string($email_from)."\n"; $email_message .= "Telephone: ".clean_string($telephone)."\n"; $email_message .= "Comments: ".clean_string($comments)."\n"; // create email headers $headers = 'From: '.$email_from."\r\n". 'Reply-To: '.$email_from."\r\n" . 'X-Mailer: PHP/' . phpversion(); @mail($email_to, $email_subject, $email_message, $headers); } ?> <form name="htmlform" method="post" action="contact.php" class="form"> <table width="600px"> </tr> <tr> <td valign="top"> <label for="first_name" class="mylabelstyle">First Name *</label> </td> <td valign="top"> <input type="text" name="first_name" maxlength="50" size="40" class="myinputstyle"> </td> </tr> <tr> <td valign="top"> <label for="last_name" class="mylabelstyle">Last Name *</label> </td> <td valign="top"> <input type="text" name="last_name" maxlength="50" size="40" class="myinputstyle"> </td> </tr> <tr> <td valign="top"> <label for="email" class="mylabelstyle">Email Address *</label> </td> <td valign="top"> <input type="text" name="email" maxlength="80" size="40" class="myinputstyle"> </td> </tr> <tr> <td valign="top"> <label for="telephone" class="mylabelstyle">Telephone Number</label> </td> <td valign="top"> <input type="text" name="telephone" maxlength="30" size="40" class="myinputstyle"> </td> </tr> <tr> <td valign="top"> <label for="comments" class="mylabelstyle">Comments *</label> </td> <td valign="top"> <textarea name="comments" maxlength="1000" cols="80" rows="10" class="myinputstyle"></textarea> </td> </tr> <tr> <td colspan="2" style="text-align:center"> <input type="submit" value="Submit"> </td> </tr> </table> </form> <br /><br /> <center> <img src="images/logo.jpg" alt=""> <br /><br /><br /> <h1>Tel/Fax: 01474 358194 - Email: gary@mannstours.co.uk</h1> </center> </div>
  7. Yeah I understand but im new to php is there away you could subject or anyone could?
  8. <?php $result = "SELECT * FROM portfolio"; $result = mysql_query ($result) or die (mysql_error()); $i=0; while($row = mysql_fetch_assoc($result)) { if($i==0) echo '<div class="portfolioPage">'; if($i==2) $divclass = 'portfolioProjectWrapper borderWhite'; else $divclass = 'portfolioProjectWrapper borderGray'; echo ' <div class="'.$divclass.'"> <a href="portfolioPage.html" class="image asyncImgLoad" title="img/'.$row['image290x290'].'"></a> <p class="imageDesc">'.$row['image290x290_phot'].'</p> <h3 class="title">'.$row['title'].'</h3> <p class="subtitle">'.$row['subtitle'].'</p> <p class="desc"> '.substr($row['description'], 0, 1200).' <a href="portfolioPage.html" class="commonLink">Read more</a> </p> </div> '; if($i==2) echo '</div>'; if(i==2) $i=0; else $i++; } ?> Please help me im backward at this been along time.
  9. I trying to make it so i can in put the data from a database into a theme i got from theme forest but im having few problems. the theme and page http://warp.nazwa.pl/dc/innovation/portfolio.html The NEXT button on the portfolio see how it slides across and works nicely here but on my page http://www.jigsawsoulmedia.com/root/Files/jigsawsoulmedia.com/_public/template.php its stopped working since I've place my php code in there and i can't see why not, everything look right to be from the html and php. Could one you lovely people see what you can spot wrong. page code with php below <!-- PAGE CONTENT HERE, PORTFOLIO LIST AND RIGHT SIDE BAR --> <div id="portoflioHeaderContainer"> <!-- PAGE TITLE AND NAVIGATION TREE --> <h1 class="commonPageTitle">Portfolio</h1> <div id="navigationTreeContainer"> <a href="index.html" class="prev">Home</a> \ <a class="current">Portfolio</a> </div> <!-- navigationTreeContainer --> <!-- SHORT TEXT THAT DESCRIBE PAGE CONTENT --> <p class="commonIntroductionText"> Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae. Nemo enim ipsam voluptatem quia <span class="spanBold">voluptas sit aspernatur</span> aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet consectetur, adipisci velit. </p> <!-- PORTFOLIO STATISTICS, CURRENT/ALL PAGE AND CURRENT/ALL PROJECT NUMBER --> <div class="portfolioStatisticsContainer"> <div class="pageStatsWrapper"> <span id="pageNumber"></span><span id="pageCount"></span> </div> <div class="imageStatsWrapper"> <span id="hoveredImageIndex">Project: 1/</span><span id="numberOfImages">0</span> </div> </div> <!-- portfolioStatisticsContainer --> </div> <!-- portoflioHeaderContainer --> <div id="portfolioContainer"> <div class="portfolioPage"> <?php $result = "SELECT * FROM portfolio"; $result = mysql_query ($result) or die (mysql_error()); $i=0; while($row = mysql_fetch_assoc($result)) { if($i==2) $divclass = 'portfolioProjectWrapper borderWhite'; else $divclass = 'portfolioProjectWrapper borderGray'; echo ' <div class="'.$divclass.'"> <a href="portfolioPage.html" class="image asyncImgLoad" title="img/'.$row['image290x290'].'"></a> <p class="imageDesc">'.$row['image290x290_phot'].'</p> <h3 class="title">'.$row['title'].'</h3> <p class="subtitle">'.$row['subtitle'].'</p> <p class="desc"> '.substr($row['description'], 0, 1200).' <a href="portfolioPage.html" class="commonLink">Read more</a> </p> </div> '; if($i==2) $i=0; else $i++; } ?> </div><!-- portfolioPage --> </div> <!-- portfolioContainer --> <!-- PORTFOLIO CONTROL PANEL --> <div id="portfolioControlPanel"> <div id="portfolioPrevPageBtn">Prev page</div> <div id="portfolioNextPageBtn">Next page</div> </div> <!-- portfolioControlPanel --> <div class="clearBoth"></div> Thanks for taking a look!
  10. @PFMaBiSmAd Error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE `id` = '43'' at line 1 <?php session_start(); $message .= $_SESSION["message"]; include('_resources/opendb.php'); $_SESSION['message'] = ""; if (empty($_POST['use'])) $_SESSION['message'] .= "<font color=red><li>You must submit in an idea.<br /></li></font>"; if (!empty($_SESSION['message'])) { $_SESSION['message'] .= "<br />"; header("Location: add.php"); exit(); } $use = mysql_real_escape_string(ucwords($_POST['use'])); $query = "INSERT INTO `uses` (`uses`) VALUES('$use')"; if (mysql_query($query)) { $id = mysql_insert_id(); } else { $_SESSION['message'] = "<font color=red><li>Couldnt Add 1</li><br /></font>"; header('Location: add.php'); } $js = "$('#$id').tipsy({gravity: 'n'});"; $js = mysql_real_escape_string($js); $query_t = "INSERT INTO `uses` (`js`) VALUES ('$js') WHERE `id` = '$id'"; if (mysql_query($query_t)) { $_SESSION['message'] = "<font color=green><li>Your idea was added below</li><br /></font>"; header('Location: index.php'); } else { exit(print(mysql_error())); $_SESSION['message'] = "<font color=red><li>Couldnt Add 2</li><br /></font>"; header('Location: add.php'); } include('_resources/closedb.php'); ?>
  11. $js = '\$(\'#' . $id . '\').tipsy({gravity: \'n\'});'; $query_t = "INSERT INTO `uses` (`js`) VALUES ('$js') WHERE `id` = '$id'"; exit($query_t); result INSERT INTO `uses` (`js`) VALUES ('\$('#39').tipsy({gravity: 'n'});') WHERE `id` = '39'
  12. result = INSERT INTO `uses` (`js`) VALUES ('\$('#36').tipsy({gravity: 'n'});')
  13. Everything above the exit(); is fine and works great. <?php session_start(); $message .= $_SESSION["message"]; include('_resources/opendb.php'); $_SESSION['message'] = ""; if (empty($_POST['use'])) $_SESSION['message'] .= "<font color=red><li>You must submit in an idea.<br /></li></font>"; if (!empty($_SESSION['message'])) { $_SESSION['message'] .= "<br />"; header("Location: add.php"); exit(); } $use = mysql_real_escape_string(ucwords($_POST['use'])); $query = "INSERT INTO `uses` (`uses`) VALUES('$use')"; if (mysql_query($query)) { $id = mysql_insert_id(); } else { $_SESSION['message'] = "<font color=red><li>Couldnt Add 1</li><br /></font>"; header('Location: add.php'); } exit(); $js = '\$(\'#' . $id . '\').tipsy({gravity: \'n\'});'; $query_t = "INSERT INTO `uses` (`js`) VALUES ('$js')"; if (mysql_query($query_t)) { $_SESSION['message'] = "<font color=green><li>Your idea was added below</li><br /></font>"; header('Location: index.php'); } else { exit(print(mysql_error())); $_SESSION['message'] = "<font color=red><li>Couldnt Add 2</li><br /></font>"; header('Location: add.php'); } include('_resources/closedb.php'); ?>
  14. yeah i've echo them both out and each have the value they should have. what do you mean by Do you know the exact offending line?
  15. I've check this, and both $use and $js both have a value everytime...
  16. yeah i know as i submit the code again above, the code you posted gave me same error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
  17. includes the right $js <?php session_start(); $message .= $_SESSION["message"]; include('_resources/opendb.php'); $_SESSION['message'] = ""; if (empty($_POST['use'])) $_SESSION['message'] .= "<font color=red><li>You must submit in an idea.<br /></li></font>"; if (!empty($_SESSION['message'])) { $_SESSION['message'] .= "<br />"; header("Location: add.php"); exit(); } $use = mysql_real_escape_string($_POST['use']); $use = ucwords($use); $query = "INSERT INTO uses (uses) VALUES ('$use')"; if (mysql_query ($query)) { $id = mysql_insert_id(); } else { $_SESSION['message'] = "<font color=red><li>Couldnt Add 1</li><br /></font>"; header('Location: add.php'); } $js = '\$(\'#' . $id . '\').tipsy({gravity: \'n\'});'; $query = "INSERT INTO `uses` (`js`) VALUES ('$js') WHERE `id` = '$id'"; if (mysql_query ($query)) { $_SESSION['message'] = "<font color=green><li>Your idea was added below</li><br /></font>"; header('Location: index.php'); } else { exit(print(mysql_error())); $_SESSION['message'] = "<font color=red><li>Couldnt Add 2</li><br /></font>"; header('Location: add.php'); } include('_resources/closedb.php'); ?>
  18. much love <?php session_start(); $message .= $_SESSION["message"]; include('_resources/opendb.php'); $_SESSION['message'] = ""; if (empty($_POST['use'])) $_SESSION['message'] .= "<font color=red><li>You must submit in an idea.<br /></li></font>"; if (!empty($_SESSION['message'])) { $_SESSION['message'] .= "<br />"; header("Location: add.php"); exit(); } $use = mysql_real_escape_string($_POST['use']); $use = ucwords($use); $query = "INSERT INTO uses (uses) VALUES ('$use')"; if (mysql_query ($query)) { $id = mysql_insert_id(); } else { $_SESSION['message'] = "<font color=red><li>Couldnt Add 1</li><br /></font>"; header('Location: add.php'); } $js = '1'; $query = "INSERT INTO `uses` (`js`) VALUES ('$js') WHERE `id` = '$id'"; if (mysql_query ($query)) { $_SESSION['message'] = "<font color=green><li>Your idea was added below</li><br /></font>"; header('Location: index.php'); } else { exit(print(mysql_error())); $_SESSION['message'] = "<font color=red><li>Couldnt Add 2</li><br /></font>"; header('Location: add.php'); } include('_resources/closedb.php'); ?>
  19. i replaced $js with $js = '\$(\'#' . $id . '\').tipsy({gravity: \'n\'});'; and had the error message You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE `id` = '23'' at line 1 does this help?
  20. $query = "INSERT INTO uses (uses) VALUES ('$use')"; if (mysql_query ($query)) { $id = mysql_insert_id(); $id = mysql_insert_id();
  21. Error Message You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
  22. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.