PHP - Stuck With A Broken Functions, Cant Figure It Out.
Hey People, Im stuck right now and I need some fresh eyes. Seems this functions someone made that I gotta fix is broken Im assuming maybe a missing bracket or one out of place.. but.. Im not seeing it, ive been staring at it for far to long tryin to fix it find the issue etc.. and its eluding me. Right now the error I am getting is "unexpected $end"
heres the function Code: [Select] function getlinkedinstoredContacts($user_id,$limit=10,$offset=1){ $query = $this->db->get_where('cm_user_linkedin_contacts', array('user_id' => $user_id,'same_company'=>'Y'),$limit,$offset); if ($query->num_rows() > 0){ $contacts = $query->result(); //Loop throught the contact list foreach ($contacts as $key => $contact){ $headline = $contact->headline; if (preg_match('/(at )| @ /', $headline)){$arr = preg_split('/(at )| @ /', $headline, 2);} elseif (preg_match('/,/', $headline)){$arr = preg_split('/,/', $headline, 2);} else{$arr[0] = $headline;$arr[1] = '';} $arr[0] = preg_replace('/^\s*/', '', $arr[0]); $arr[0] = preg_replace('/\s*$/', '', $arr[0]); $arr[1] = preg_replace('/^\s*/', '', $arr[1]); $arr[1] = preg_replace('/\s*$/', '', $arr[1]); $current_company_position = $arr[0]; // job_title $current_company_name=$arr[1]; //company //for testing if ($counter > 21){unset($contacts[$key]);} else{ $contact->job_title=$current_company_position; $contact->current_company=$current_company_name; if ($contact->picture_url == ''){ $contact->picture_url = $this->config->item('base_url') . "static/images/avatar-large.jpg')"; $contacts[$key]=$contact; $counter++; } } return $contacts; } return null; } Similar TutorialsHi all ! I have a script I am putting together that simulate a cricket game. The only issue is, that there are a huge number of functions because there doesn't seem to be any other way to do this properly. As well as this, there a while() loop and all this seems to be leading to the page reaching a max 30 second timeout when generating the result. My code is attached below, it is quite messy at the moment because i've just be working on it, but I was wondering if anyone has any solutions of how I can speed this up or change to prevent a timeout: <?php // Error reporting error_reporting(E_ALL); // Connect DB mysql_connect("wickettowicket.adminfuel.com", "rockinaway", "preetha6488") or die(mysql_error()); // Select DB mysql_select_db("wickettowicket") or die(mysql_error()); // MySQL queries to find batsmen and bowlers $array_batsmen = mysql_query('SELECT id, name, ability, strength FROM wtw_players WHERE team_id = 1 ORDER BY id ASC'); $array_bowlers = mysql_query('SELECT id, name, ability, strength FROM wtw_players WHERE team_id = 2'); // Start table for data $data = '<table width="600px">'; // Create blank scorecard while ($array_bat = mysql_fetch_array($array_batsmen)) { $data .= '<tr><td>'.$array_bat['name'].'</td><td></td><td></td><td>0</td></tr>'; } // Set up arrays for players $current_batsman = $current_bowler = array(); // Reset query mysql_data_seek($array_batsmen,0); $in_one = $in_two = $it = ''; function currentBatsman($id, $name, $ability, $strength, $out, $in, $runs) { global $current_batsman; $current_batsman = array ( 'id' => $id, 'name' => $name, 'ability' => $ability, 'strength' => $strength, 'out' => $out, 'in' => $in, 'runs' => $runs ); echo 'set current'; } // Set up arrays of batsmen while ($array = mysql_fetch_array($array_batsmen)) { if ($it < 3 && $in_one == '') { currentBatsman($array['id'], $array['name'], $array['ability'], $array['strength'], 0, 1, 0); $batsmen[$array['id']] = array ( 'id' => $array['id'], 'name' => $array['name'], 'ability' => $array['ability'], 'strength' => $array['strength'], 'out' => 0, 'in' => 1, 'runs' => 0 ); $in_one = $array['id']; $current = $array['id']; $it++; } else if ($it < 3 && $in_two == '') { $batsmen[$array['id']] = array ( 'id' => $array['id'], 'name' => $array['name'], 'ability' => $array['ability'], 'strength' => $array['strength'], 'out' => 0, 'in' => 1, 'runs' => 0 ); $in_two = $array['id']; $it++; } else { $batsmen[$array['id']] = array ( 'id' => $array['id'], 'name' => $array['name'], 'ability' => $array['ability'], 'strength' => $array['strength'], 'out' => 0, 'in' => 0, 'runs' => 0 ); } } // Bowler Array while ($array = mysql_fetch_array($array_bowlers)) { $bowlers[] = array ( 'name' => $array['name'], 'ability' => $array['ability'], 'strength' => $array['strength'] ); } // Reset both queries mysql_data_seek($array_bowlers,0); mysql_data_seek($array_batsmen,0); function changeBatsman($just_out) { global $array_batsmen, $batsmen; //Update array $batsmen[$just_out] = array ( 'in' => 1, 'out' => 1 ); while ($array = mysql_fetch_array($array_batsmen)) { if ($just_out != $array['id'] && $batsmen[$array['id']]['out'] != 0) currentBatsman($array['id'], $array['name'], $array['ability'], $array['strength'], 0, 1, 0); } // Reset query mysql_data_seek($array_batsmen,0); echo 'change batsman'; } function swapBatsman($other_batsman) { global $array_batsmen, $batsman; while ($array = mysql_fetch_array($array_batsmen)) { if ($other_batsman != $array['id'] && $batsman[$array['id']]['out'] != 0 && $batsman[$array['id']]['in'] == 1) currentBatsman($array['id'], $array['name'], $array['ability'], $array['strength'], 0, 1, 0); } // Reset query mysql_data_seek($array_batsmen,0); echo 'swap batsman'; } $runs = $outs = $balls = $overs = 0; $played = array(); function selectBowler() { global $bowlers, $current_bowler; // Select random bowler $choose_bowler = array_rand($bowlers, 1); $current_bowler = array ( 'name' => $bowlers[$choose_bowler]['name'], 'ability' => $bowlers[$choose_bowler]['ability'], 'strength' => $bowlers[$choose_bowler]['strength'] ); } /* function selectBatsman(); { global $array_batsmen; while ($array_batsmen[]['out'] != 1) { }*/ function bowl() { global $batsmen, $bowlers, $current_bowler, $current_batsman, $data, $balls, $outs, $runs; if ($current_batsman['out'] == 0) { echo 'bowling'; // Set the initial number $number = rand(0, 190); // Ability of batsman if ($current_batsman['ability'] > 90) $number += 30; else if ($current_batsman['ability'] > 70) $number += 15; else if ($current_batsman['ability'] > 50) $number += 2; else $number = $number; // Strength of batsman if ($current_batsman['strength'] > 90) $number += 15; else if ($current_batsman['strength'] > 70) $number += 10; else if ($current_batsman['strength'] > 50) $number += 5; else $number = $number; // Depending on overs if ($balls > 270) $number += 30; else if ($balls > 120) $number -= 10; // Ability if ($current_bowler['ability'] > 90) $number -= 30; else if ($current_bowler['ability'] > 70) $number -= 15; else if ($current_bowler['ability'] > 50) $number -= 2; else $number = $number; // If batsman has made a huge total of runs, we need to knock some numbers off - more likely to get out if ($current_batsman['runs'] > 200) $number -= 70; else if ($current_batsman['runs'] > 100) $number -= 30; // Finally sort out runs if ($number > 190) $run = 6; else if ($number > 170) $run = 4; else if ($number > 160) $run = 3; else if ($number > 100) $run = 2; else if ($number > 50) $run = 1; else if ($number > 10) $run = 0; else if ($balls > 120 && $number > 0) $run = 0; else $run = -1; // Increase number of balls $balls += 1; // Are they out? if ($run == -1) { $current_batsman['out'] = 1; $played[] = $current_batsman['id']; $find = '<tr><td>'.$current_batsman['name'].'</td><td></td><td></td><td>0</td></tr>'; $replace = '<tr><td>'.$current_batsman['name'].'</td><td></td><td>'.$current_bowler['name'].'</td><td>'.$current_batsman['runs'].'</td></tr>'; $data = str_replace($find, $replace, $data); changeBatsman($current_batsman['id']); echo 'out'; } else { $current_batsman['runs'] += $run; $runs += $run; if ($run == 1 || $run == 3) { swapBatsman($current_batsman['id']); echo 'time to swap'; } echo $run; } // Count outs if ($current_batsman['out'] == 1) $outs += 1; } } function game() { global $main, $batsmen, $bowlers, $data, $batted, $balls, $outs, $current_batsman; // Check if possible while ($balls <= 295 && $outs < 10) { selectBowler(); // Actually bowl now bowl(); } } game(); echo $data; I teaching myself php, but I am coming from java and other compiled languages, so the process has been a little bumpy. I am trying to do something like this: Code: [Select] class my_class { function one () { $two = two (); $three = three (); $five = $two + $three; return $five; } function two () { $two = 2; return $two; } function three () { $three = 3; return $three; } } Unfortunately, I keep getting an error message saying that my call to two () is an undefined function. I am gathering from this that the scope of one () is not aware of the existence of two (). Is there a way to get around this so I can call two () and three () from one ()? I get a php error...Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given $sql = "SELECT `pm_messages`.`conversation_id` FROM `pm_messages` GROUP BY `pm_messages`.`conversation_id` WHERE `pm_messages`.`conversation_id` = ${conversation['id']}"; $result = mysql_query($sql); $replies = mysql_fetch_assoc($result); Much of the PHP documentation is broken into very small pages. I find that this makes it very difficult to use. Does anyone else find this? I have a hackish but useful program which takes the PHP single-file documentation and splits it into one page per extension, ensuring that links between pages work correctly. It works quite well. I wonder if anyone else would find this useful? If so, then I should have time in the next few weeks to clean it up and make it publicly available. this doesnt work and ive spent ages trying to figure it out
its the bit with else
<?php //CORS header header("Access-Control-Allow-Origin: *"); //Capture parameter $create = $_POST['create']; $fuser = $_POST['fuser']; if (!file_exists("uploads/$fuser/$create")); { if ($f = fopen("uploads/$fuser/$create", 'w')) { fwrite($f, 1); fclose($f); echo 'OK'; } } else { $f = fopen("uploads/$fuser/$create", 'w') fwrite($f, 5); fclose($f); echo 'FAIL' ; } ?>this bit does work below, its until i try to do else if , or else <?php //CORS header header("Access-Control-Allow-Origin: *"); //Capture parameter $create = $_POST['create']; $fuser = $_POST['fuser']; if (!file_exists("uploads/$fuser/$create")); { if ($f = fopen("uploads/$fuser/$create", 'w')) { fwrite($f, 1); fclose($f); echo 'OK'; } }help I copied the code for password_hash at php.net: <?php /** * In this case, we want to increase the default cost for BCRYPT to 12. * Note that we also switched to BCRYPT, which will always be 60 characters. */ $options = [ 'cost' => 12, ]; echo password_hash("rasmuslerdorf", PASSWORD_BCRYPT, $options); ?> and changed it for use in my login page:
$options = ['cost' => 12,]; $user = mysqli_real_escape_string($db_link,$_GET['username']); $pass = password_hash($_GET['password'], PASSWORD_BCRYPT, $options); but my page keeps saying invalid user/pass. Upon echoing the $pass I find that the result changes EACH time. so I created a test page that runs the code from php.net (verbatim code) 20x and I got: [pre]
$2y$10$Nlf0J520viR4C5jd3nIdd.6M3OMKACx503Jm3PiXDYZIs.13XAheq [/pre] Is password_hash broken? or am I mistaken to think that it's supposed to return the same output everytime fror the same input? Edited March 17, 2019 by Karaethontypos corrected I'm very out of practice, and trying to figure out old broken code. From a previous search page, results are pulled from the database, and the variables are passed. At first it works, but then, when I click on the pagination links to see the next page of results, it stops working. The next page appears with no info. Here's the code, I think it has something to do with the passed variables toward the bottom of the code, but I can't figure out what to do. <code> <?php require ('databaseconnection'); $display = 2; // it's intentionally only 2 for the moment to test pagination if (isset($_GET['np'])) { $num_pages = $_GET['np']; } else { $data = "SELECT COUNT(*), `descriptors`.*, `plantae`.* FROM `descriptors` LEFT JOIN `plantae` ON (`descriptors`.`plant_id` = `plantae`.`plant_name`) WHERE `leaf_shape` LIKE '%$s1%' AND `leaf_venation` LIKE '%$s3%' AND `leaf_margin` LIKE '%$s4%'"; $result = mysql_query ($data); if (!$result) { die("Oops, my query failed. The query is: <br>$data<br>The error is:<br>".mysql_error()); } $row = mysql_fetch_array($result, MYSQL_NUM); //row 40 above seems to be where a problem is $num_records = $row[0]; if ($num_records > $display) { $num_pages = ceil ($num_records/$display); } else { $num_pages = 1; } } if (isset($_GET['s'])) { $start = $_GET['s']; } else { $start = 0; } if(isset($_GET[submitted])) { // Now collect all info into $item variable $shape = $_GET['s1']; $color = $_GET['s2']; $vein = $_GET['s3']; $margin = $_GET['s4']; // This will take all info from database where row tutorial is $item and collects it into $data variable $data = mysql_query("SELECT `descriptors`.* ,`plantae`.* FROM `descriptors` LEFT JOIN `plantae` ON (`descriptors`.`plant_id` = `plantae`.`plant_name`) WHERE `leaf_shape` LIKE '%$s1%' AND `leaf_venation` LIKE '%$s3%' AND 'leaf_margin' LIKE '%$s4%' ORDER BY `plantae`.`scientific_name` ASC LIMIT $start, $display"); //chs added this in... echo '<table align="center" cellspacing="0" cellpading-"5"> <tr> <td align="left"><b></b></td> <td align="left"><b></b></td> <td align="left"><b>Leaf margin</b></td> <td align="left"><b>Leaf venation</b></td> </tr> '; while($row = mysql_fetch_array($data)){ echo '<tr> <td align="left"> <a href="view_plant.php?id=' . $row['plant_name'] . '">View plant</a> </td> <td align="left"> </td> <td align="left">' . $row['scientific_name'] . '</td> <td align="left">' . $row['common_name'] . '</td> <td align="left">' . $row['leaf_shape'] . '</td> </tr>'; } echo '</table>'; } if ($num_pages > 1) { echo '<br /><p>'; $current_page = ($start/$display) + 1; if ($current_page != 1) { echo '<a href="leafsearch4c.php?s=' . ($start - $display) . '&np=;' . $num_pages . '&s1=' . $s1 . '&s2=' . $s2 . '&s3=' . $s3 . '&s4=' . $s4 . '">Previous</a> '; } for ($i = 1; $i <= $num_pages; $i++) { if($i != $current_page) { echo '<a href="leafsearch4c.php?s=' . (($display * ($i - 1))) . '$np=' . $num_pages . '&s1=' . $s1 . '&s2=' . $s2 . '&s3=' . $s3 . '&s4=' . $s4 .'">' . $i . '</a>'; } else { echo $i . ' '; } } if ($current_page != $num_pages) { echo '<a href="leafsearch4c.php?s=' . ($start + $display) . '$np=' . $num_pages . '&s1=' . $s1 . '&s2=' . $s2 . '&s3=' . $s3 . '&s4=' . $s4 .'"> Next</a>'; } } //added curly ?></code> I recently changed hosts, now my image uploader which used to work fine doesn't work. $indeximage = $_FILES['indeximage']; if($indeximage) { $indeximagename = basename($_FILES['indeximage']['name']); $indeximagenew = $_SERVER['DOCUMENT_ROOT'] . '/images/uploaded/index/' . $indeximagename; if (!file_exists($indeximagenew)) { if ((move_uploaded_file($_FILES['indeximage']['tmp_name'], $indeximagenew)) === true) { echo 'Index Image uploaded to this address '; echo 'http://www.address.co.uk/images/uploaded/index/'; echo $indeximagename; echo '<br />'; }else { echo 'Unable to move Index Image into the right folder.'; } } } It now echos Unable to move Index Image into the right folder. I tried putting: ini_set("display_errors", "1"); error_reporting(E_ALL); at the beginning. Before the upload it reads: Notice: Undefined index: images in /var/www/vhosts/huhmagazine.co.uk/httpdocs/admin/images.php on line 58 Notice: Undefined index: indeximage in /var/www/vhosts/huhmagazine.co.uk/httpdocs/admin/images.php on line 62 After it reads: Warning: move_uploaded_file(): Unable to move '/tmp/phpTd67fh' to '/var/www/vhosts/huhmagazine.co.uk/httpdocs/images/uploaded/index/calidewitt.jpg' in /var/www/vhosts/huhmagazine.co.uk/httpdocs/admin/images.php on line 71 Hi I am a php learner and I am having some problems while loading images from templates. I will explain everything so hope you can understand my question.. My Folder Structure WEB SITE NAME - index.php [default landing page] + Images [images folder] + css [css folder] + templates [templates folder] |-- header.inc.php [header template] |-- footer.inc.php [footer template] + includes [folder for all classes and variables] + js [folder for all js files] + contact-us [this is a folder] |--index.php [this is the file inside the contact-us folder] + about-us [this is a folder] |-- index.php [this is the file inside the about-us folder] This is the header.inc.php file [just a example to let you understand my problem] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "URL/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="URL/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Web Site Name</title> <link href="css/reset.css" rel="stylesheet" type="text/css" /> <link href="css/default.css" rel="stylesheet" type="text/css" /> <script type="text/javascript" src="js/jquery-1.4.4.min.js"></script> </head> <body> <img src="images/phpmadeeasy.jpg" width="200" height="70" alt="php made easy logo" /> </body> ------------------------------------------------------------------------------ This is a sample main landing index.php page [i added codes only where i get into problems] <?php include_once('includes/header.inc.php') ?> <div id="mainWrapper"> <img src="images/phpbigbanner.jpg" width="200" height="70" alt="php big banner" /> </div> <?php include_once('includes/footer.inc.php') ?> ------------------------------------------------------------------------------ As you can guess, default index.php file works fine... load both logo and banner images but... this is the index.php file located under the about-us folder <?php include_once('includes/header.inc.php') ?> <div id="mainWrapper"> <img src="../images/phpbigbanner.jpg" width="200" height="70" alt="php big banner" /> </div> <?php include_once('includes/footer.inc.php') ?> ------------------------------------------------------------------------------ Here only the banner image load because the template file still show the logo image path as "images/phpmadeeasy.jpg" instead of "../images/phpmadeeasy.jpg" so is there any way me to define the default image folder as a variable so i can use that variable to load images from any directory level Example: <?php echo $images; ?>images/phpmadeeasy.jpg" <script type="text/javascript" src="<?php echo $js; ?>/jquery-1.4.4.min.js" <link href="<?php echo $css; ?>reset.css" rel="stylesheet" type="text/css" Thanks........... If I have a web page located he www . company . com / how-to-repair-your-computer.html
And I decide to re-structure my website like this www . company . com / articles / how-to-repair-your-computer.html
How do I make sure that people don't search and end up at the old, now broken, link?
It seem inevitable that as a website grows, that you will want to re-organize things. What is the best way to make sure that anyone who searches or clicks on an old link - say from an email from a friend - doesn't get a 404 error?
Also, how do you avoid ruining a web pages rank on Google after you move things? (I think if the URL changes, Google makes you start all over as far as getting listed on page-1 and all of that?
Is this something I have to hande on my end, or is it a Google issue, or something else?
[ m ]printf[/ m]produces a link to
php.net/<span>printf
Unless you use nobbc tags, then it works fine ???
Edited by Barand, 24 November 2014 - 02:25 PM. Hi I am a php learner and I am having some problems while loading images from templates. I will explain everything so hope you can understand my question.. My Folder Structure WEB SITE NAME - index.php [default landing page] + Images [images folder] + css [css folder] + templates [templates folder] |-- header.inc.php [header template] |-- footer.inc.php [footer template] + includes [folder for all classes and variables] + js [folder for all js files] + contact-us [this is a folder] |--index.php [this is the file inside the contact-us folder] + about-us [this is a folder] |-- index.php [this is the file inside the about-us folder] This is the header.inc.php file without some html markups Quote <title>Web Site Name</title> <link href="css/reset.css" rel="stylesheet" type="text/css" /> <link href="css/default.css" rel="stylesheet" type="text/css" /> <script type="text/javascript" src="js/jquery-1.4.4.min.js"></script> </head> <body> <img src="images/phpmadeeasy.jpg" width="200" height="70" alt="php made easy logo" /> </body> ------------------------------------------------------------------------------ This is a sample main landing index.php page [i added codes only where i get into problems] Quote <?php include_once('includes/header.inc.php') ?> <div id="mainWrapper"> <img src="images/phpbigbanner.jpg" width="200" height="70" alt="php big banner" /> </div> <?php include_once('includes/footer.inc.php') ?> ------------------------------------------------------------------------------ As you can guess, default index.php file works fine... load both logo and banner images but... this is the index.php file located under the about-us folder Quote <?php include_once('includes/header.inc.php') ?> <div id="mainWrapper"> <img src="../images/phpbigbanner.jpg" width="200" height="70" alt="php big banner" /> </div> <?php include_once('includes/footer.inc.php') ?> ------------------------------------------------------------------------------ Here only the banner image load because the template file still show the logo image path as "images/phpmadeeasy.jpg" instead of "../images/phpmadeeasy.jpg" so is there any way me to define the default image folder as a variable so i can use that variable to load images from any directory level Example: Quote <?php echo $images; ?>images/phpmadeeasy.jpg" <script type="text/javascript" src="<?php echo $js; ?>/jquery-1.4.4.min.js" <link href="<?php echo $css; ?>reset.css" rel="stylesheet" type="text/css" Thanks........... Ok mixing javascript with php.... im having bugs . I basically want to replace any broken image links with a picture "noimage.gif" in the images folder. I tried this code but am getting the error: Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /home/wormste1/public_html/tilburywebdesign/shop/FTPServers/barryottley/showroom.php on line 78 This is the javascript header - all seems fine: <script language="JavaScript" type="text/javascript"> function ImgError(source){ source.src = "/images/noimage.gif"; source.onerror = ""; return true; } </script> this is the code thats erroring... is it the way ive written in the code into the IMG tag? while($row = mysql_fetch_array($result)){ echo "<TABLE CELLPADDING=0 CELLSPACING=0 WIDTH=100% BORDER=0>"; echo "<TR />"; echo "<TD WIDTH=30% VALIGN=TOP />"; echo " <A HREF='images/".$row['photo']."' target=_blank><IMG SRC='images/".$row['photo']."' width=186 height=155 border=0 onerror="ImgError(this);" /></A> "; echo "<br />"; echo "</TD>"; echo "<TD WIDTH=10 VALIGN=TOP />"; So on my website I have a basic if statement that checks some arguments to see if a user can add another user as a friend. Well I had gotten that part down and for the longest time other people on my website have been able to use the feature. Now all of a sudden the if statement doesn't work? Why? Here is the statement: if ($privacy['privacy']['who_can_add'] == '1' AND $zext->user['id'] != '0' AND $zext->user['id'] != $u['id']) { $add_friend = $u['add_friend']; } of course if I put $add_friend outside the if statement, the button appears. How can a statment work one day but not the other? Is it an issue with my server? dump of $privacy: Code: [Select] $ => Array (4) ( | ['hide_o_status'] = Integer(1) 0 | ['who_can_view'] = Integer(1) 1 | ['who_can_add'] = Integer(1) 1 | ['who_can_contact'] = Integer(1) 1 ) dump of $zext->user['id']: Code: [Select] $ = String(2) "10" dump of $u['id']: Code: [Select] $ = String(2) "4" it all has correct information and the if statement has not been changed from before when it had worked and outputted $add_friend all day long. it worked until last night, i don't know what happened or why, php version has not been changed or anything. if anybody has any ideas on what's going on help would be much appreciated. Thanks, Matt. OK, hello everyone from your newest newbie - to this forum anyway. First thing to say is I do not claim to be the best php coder there is - as you will see when you look at my code ! Secondly, I have scoured/googled many sources to try and understand an answer to my problem without success. So, please first look at this page - http://www.thepearsons-ws.co.uk/php/MetMonthly.php If you pick March 2011 say you see a list of data presented on the same page. This is the effect I want to get to with a GD graph. If you now try my first attempt - http://www.thepearsons-ws.co.uk/php/raingraph3monthlyselect.php - and pick March 2011 and Submit AND click the link you get a graph on a new page. OK, but now what I want - I want the image on that same first page. So, I have the attached code which produces this - http://www.thepearsons-ws.co.uk/php/raingraph3monthlyselect2.php I have hacked the code around a bit but basically it's - PHP - form and data selection HTML - form with pull downs PHP - display graph. The image is broken. If I remove the HTML block completely it produces output but of course I can not vary the selection. Any small element of HTML here destroys the image - no whitespace or such - just <html> is enough. So, any clues on how to correctly structure this code would be greatly appreciated. Regards Phil $compQ = "SELECT companies.companyid, companies.companyname, companies.companylogo, companies.companyoccupation, companies.industry, eQuestions.capitalrequested FROM companies LEFT JOIN eQuestions ON companies.companyid = eQuestions.companyid"; This is not displaying data correctly. I'm assuming eQuestions.capitalrequested is not in the correct spot? Hi guys im ben from Liverpool and im making an online store in php, and have been following a tutorial. the problem is my site so far is on wampserver. When i upload the database and php files to an online host my work just does not show. Has any1 got any advice or willing to help me? i would much appreciate it! I've been stuck too long for my beginner brain. Here is the majority of the code: Code: [Select] mysql_connect($host, $dbusername, $password); mysql_select_db($TxQuizdb); $quizquery = mysql_query("SELECT Id, Total_Questions, Maximum_Score, Passing_Score, Correct_Answer FROM Module_1_Quiz WHERE Id = '1'"); $quizqueryresult = mysql_fetch_array($quizquery); $totalq = $quizqueryresult['Total_Questions']; $maxscore = $quizqueryresult['Maximum_Score']; $passingscore = $quizqueryresult['Passing_Score']; $qvalue = $maxscore / $totalq; //scoring values $Score=0; $ansquery = mysql_query("SELECT Correct_Answer FROM Module_1_Quiz"); $QChoice_1 = $_POST['QChoice_1']; $QChoice_2 = $_POST['QChoice_2']; while ($answers = mysql_fetch_array($ansquery)) { $i++; if ($_POST['QChoice_$i'] == $answers['Correct_Answer']) { $Score = round(($Score + $qvalue), 0); } else { echo "wrong";} } The problem i am running into is trying to score this quiz with the following: Code: [Select] while ($answers = mysql_fetch_array($ansquery)) { $i++; if ($_POST['QChoice_$i'] == $answers['Correct_Answer']) { $Score = round(($Score + $qvalue), 0); } else { echo "wrong";} } I can't get the "if" statement to satisfy.....and am about to rip my eyes out... thanks! Okay, I have a P value field in my Database ROW. It contains 0,1,2 0 is my About Me, 1 is my Signature Section 2 is my Friends section: Check this screenshot: Now you see that little green arrow? When you click on it, I have the code for it he Code: [Select] if (isset($ibforums->input['down'])){ if ($ibforums->input['down'] == "0"){ $new = '1,0,2'; } $DB->query("UPDATE ibf_members set p='$new' WHERE id={$ibforums->member['id']}"); header("Location: ?i={$ibforums->input['i']}"); } As you can see, it updates it 1,0,2. (Default is 0,1,2) for variable $p. Here is my code. Code: [Select] $p = explode(",", $member['p']); $middle=array ( "0" => array ( "section" => $aboutme, "b" => "banana", "c" => "apple" ), "1" => array ("section" => $signature, "b" => "banana", "c" => "apple" ), "2" => array ("section" => $f, "b" => "banana", "c" => "apple" ), ); $order = $p; print_r($middle); foreach ($order as $index) { $middlesection.= $middle[$index]['section']; } I echo out my $middlesection variable in my profile page, that's the screenshot that you see. My problem is, How can I check the input's when they click the green arrow button to know "not to go down anymore", I will be adding a up Arrow icon next to it... (I am very lost and little bit confused on how to check the input to make it all work) see like right now, on that screenshot it is: 1,0,2 (Signature,Aboutme,Friends) but if I click on that arrow again, how do I Dynamically make the 0 make sure it is the last one? but then see if I have to switch the 0 to 1,2,0 how would I check input on my 2 to know if it was the last one to move over to the second "," ?? It's just so confusing, (am I doing it wrong? it seems really confusing) But yeah... I appreciate your responses, hope you can guide,help me to get this done. |