Jump to content

wix100

Members
  • Posts

    16
  • Joined

  • Last visited

wix100's Achievements

Member

Member (2/5)

0

Reputation

  1. Hi Guys - me again (sorry) So, now have the code of: <?php session_start(); ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL); if(isset($_GET['ID'])){ //Connect to the database $mysqli = new mysqli("localhost", "jj3wg2td_wix", "BLAH BLAH", "BLAH BLAH"); $ID=mysqli_real_escape_string($mysqli, $_GET['ID']); $sql="SELECT * FROM uni2020 WHERE UniversityCourses='$ID'"; $result=mysqli_query($mysqli,$sql) or die ("Bad Query: $sql"); if($result->num_rows > 0); if(isset($_GET['ID'])){ $Website=mysqli_real_escape_string($mysqli,$_GET['Website']); $UcasPointsRequired=mysqli_real_escape_string($mysqli,$_GET['UcasPointsRequired']); $OverallScore=mysqli_real_escape_string($mysqli,$_GET['OverallScore']); } $row=mysqli_fetch_array($result); }else{ header('Location: Uni Results.php'); } ?> <section> <?php echo $row['Website']?> <?php echo $row['UcasPointsRequired']?> <?php echo $row['OverallScore']?> </section> I was missing the: if($result->num_rows > 0); Correct? This now returns the results (thanks) but am now getting the error: "Notice: Undefined index" on each OUTPUT ECHO line...
  2. Hi both, and thanks again! I can only apologise for my ignorance (stupidity), but am reading that I have missed the: $row=mysqli_fetch_array($result); } at the end, to fetch the data? so PHP code now being: <?php session_start(); ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL); //Connect to the database $mysqli = new mysqli("localhost", "BLAHBLAH", "BLAHBLAH", "BLAHBLAH"); if(isset($_GET['post'])){ $ID=mysqli_real_escape_string($mysqli, $_GET['ID']); $sql="SELECT * FROM uni2020 WHERE UniversityCourses='$ID'"; $result=mysqli_query($mysqli,$sql) or die ("Bad Query: $sql"); $row=mysqli_fetch_array($result); if(isset($_GET['post'])){ $Website=mysqli_real_escape_string($mysqli,$_GET['Website']); $UcasPointsRequired=mysqli_real_escape_string($mysqli,$_GET['UcasPointsRequired']); $OverallScore=mysqli_real_escape_string($mysqli,$_GET['OverallScore']); $sql= "INSERT INTO UniversityCourses (Website, UcasPointsRequired) VALUES ('$Website', $UcasPointsRequired');"; $result=mysqli_query($mysqli,$sql) or die ("Bad Query: $sql"); } $row=mysqli_fetch_array($result); } ?> <content> <?php echo $row['Website']?> <?php echo $row['UcasPointsRequired']?> <?php echo $row['OverallScore']?> </content> but this brings back the same error of: "Notice: Undefined variable: row in" Am sure I am over complicating all of this....but I am trying, I promise! Thanks again!
  3. Hi NotionCommotion - thanks for getting back at lightning speed!! There's a clue in there somewhere! I thought you might have been pointing to the order that I had put the code....thinking that the $mysqli connection string needed to be lower, so that it connected to the database once the $_GET code was evident? if(isset($_GET['post'])){ //Connect to the database $mysqli = new mysqli("localhost", "BLAHBLAH", "BLAHBLAH", "BLAHBLAH"); $ID=mysqli_real_escape_string($mysqli, $_GET['ID']); //BLAHBLAHBLAHBLAH I know I'm missing something very simple!?
  4. Hello all - am looking for help with dynamic links in PHP not returning data and coughing out "Notice: Undefined variable: row in /home/jj3wg2td/public_html/Uni More Info.php on line 200" The initial search is being fed from a mysql into table of results in another page ('ViewMore' being a column in my database and 'UniversityCourses' being the trigger to search that column): echo "<td class='result'><a href='Uni More Info.php?ID={$row['UniversityCourses']}'>{$row['ViewMore']}</a></td>"; This is working fine as I can see the various links changing when you hover over them in the table. clicking the links goes to "Uni More Info.php" where my PHP code is: <?php session_start(); ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL); //Connect to the database $mysqli = new mysqli("localhost", "jj3wg2td_wix", "MYPASSWORD", "MYDATABASE"); if(isset($_GET['post'])){ $ID=mysqli_real_escape_string($mysqli, $_GET['ID']); $sql="SELECT * FROM uni2020 WHERE UniversityCourses='$ID'"; $result=mysqli_query($mysqli,$sql) or die ("Bad Query: $sql"); $row=mysqli_fetch_array($result); if(isset($_GET['post'])){ $Website=mysqli_real_escape_string($mysqli,$_GET['Website']); $UcasPointsRequired=mysqli_real_escape_string($mysqli,$_GET['UcasPointsRequired']); $OverallScore=mysqli_real_escape_string($mysqli,$_GET['OverallScore']); $sql= "INSERT INTO UniversityCourses (Website, UcasPointsRequired) VALUES ('$Website', $UcasPointsRequired');"; $result=mysqli_query($mysqli,$sql) or die ("Bad Query: $sql"); } } ?> <content> <?php echo $row['Website']?> <?php echo $row['UcasPointsRequired']?> <?php echo $row['OverallScore']?> </content> The error codes are showing: Notice: Undefined variable: row in /home/jj3wg2td/public_html/Uni More Info.php on line 200 Notice: Undefined variable: row in /home/jj3wg2td/public_html/Uni More Info.php on line 201 Notice: Undefined variable: row in /home/jj3wg2td/public_html/Uni More Info.php on line 202 Which is the section in-between the <content></content> tags. Reading up into "Undefined Variable", it suggest that I havent "Declared the variables", but isn't that this section?: if(isset($_GET['post'])){ $Website=mysqli_real_escape_string($mysqli,$_GET['Website']); $UcasPointsRequired=mysqli_real_escape_string($mysqli,$_GET['UcasPointsRequired']); $OverallScore=mysqli_real_escape_string($mysqli,$_GET['OverallScore']); I am new to PHP and am learning as I go along....but yet again...I'm stumped! Any help is very much appreciated (again)!!!! Steven
  5. Hello Psycho Apologies for the late reply! It takes me a while to get my head around these things, and didn't want to bombard you with messages! Your advice and support is second to none, and after a few tweaks (my fault in wording) it works perfectly!!! I was certainly trying to do too many things at once....that's the story of my life!! I cannot thank you enough and wish you all the best!!! Thanks a million (learned a lot) Steven
  6. Hi all, I find myself in need again on PHP coding and the support last time was outstanding (no creeping here) so I am trying my luck again! I am trying to use a HREF link (lots of individual ones) to search a Mysql database and return the results in a PHP page. Example of HREF links on the page are here: https://flighteducation.co.uk/Create.html and in theory you click a career and it 'gets' and 'shows' the data from the database here: https://flighteducation.co.uk/Careers.php so, you click the 'Animator' link ->it goes to my database and drags back all the data to the Careers.php page So far this is what I have managed to not get right: HTML (screen shot added/attached Links.png) <a href="Careers Results.php?jobTitle=Animator"> PHP $id = $_GET['jobTitle']; if( (int)$id == $id && (int)$id > 0 ) { $link = mysqli_connect('localhost','MYUSERNAME','MYPASSWORD','MYDATABASE'); // Connect to Database if (!$link) { die('Could not connect: ' . mysqli_connect_error()); } $sql='SELECT * FROM careers WHERE jobTitle=' .$id; $result = mysqli_query($link,$sql); $row = mysqli_fetch_array($result); echo $row['jobTitle']; echo $row['jobDescription']; } else { echo "Record NOT FOUND"; } Up to now the code returns "Record NOT FOUND" so it is passing through the php to the end. I am new to PHP and trying to get my head around it all, and in theory this is the kind php code that I should be looking at, but I am still very new to it!! Any help or advice very much appreciated again!!! Thanks
  7. Maybe thats been the problem all along.....it has driven me mental (more mental), will contact the hosts and get them to do it as I cannot access/upgrade it from here! Thanks again Mr!!
  8. Unsure if this is what you mean but: Versionmysqlnd 5.0.12-dev - 20150407 - $Id: 38fea24f2847fa7519001be390c98ae0acafe387 $ All I have done is turn the error reporting off in the code, and all works fine now (am sure to coding gurus, it would drive you mad knowing there was a glitch)! As I say....I cannot praise and thank you enough!!!!! Steven
  9. gw1500se - I am sure I am annoying you and I profusely apologise....but I also think you are a genius!!!! (please see image) This is the first time I have managed to get anything from it in 6-7 weeks!! It still shows: Warning: mysqli::__construct(): Headers and client library minor version mismatch. Headers:50646 Library:50528 in /home/jj3wg2td/public_html/Careers Connect.php on line 8 which is: (<$mysqli = new mysqli("localhost", "jj3wg2td_steven", "PASSWORD", "jj3wg2td_careerslist");>) but am grinning from ear to ear currently!!
  10. I can only apologise, I am trying very much! line 15 is: (<if($result->num_rows > 0)>) I have taken your advise on the php and mysqlnd version, as I believed that was the problem this morning, but after sorting, they seem to be running the same versions now? Images attached. Many thanks again! Steven
  11. Thanks also Barand!!! Wrapped $search in ' ' and now receive: Warning: mysqli::__construct(): Headers and client library minor version mismatch. Headers:50646 Library:50528 in /home/jj3wg2td/public_html/Careers Connect.php on line 8 Notice: Undefined index: Job Title in /home/jj3wg2td/public_html/Careers Connect.php on line 19 Notice: Undefined index: Job Description in /home/jj3wg2td/public_html/Careers Connect.php on line 20 Notice: Undefined index: Salary Low in /home/jj3wg2td/public_html/Careers Connect.php on line 21 Notice: Undefined index: Salary High in /home/jj3wg2td/public_html/Careers Connect.php on line 22 Notice: Undefined index: Job Title in /home/jj3wg2td/public_html/Careers Connect.php on line 19 Notice: Undefined index: Job Description in /home/jj3wg2td/public_html/Careers Connect.php on line 20 Notice: Undefined index: Salary Low in /home/jj3wg2td/public_html/Careers Connect.php on line 21 Notice: Undefined index: Salary High in /home/jj3wg2td/public_html/Careers Connect.php on line 22 Notice: Undefined index: Job Title in /home/jj3wg2td/public_html/Careers Connect.php on line 19 Notice: Undefined index: Job Description in /home/jj3wg2td/public_html/Careers Connect.php on line 20 Notice: Undefined index: Salary Low in /home/jj3wg2td/public_html/Careers Connect.php on line 21 Notice: Undefined index: Salary High in /home/jj3wg2td/public_html/Careers Connect.php on line 22 Notice: Undefined index: Job Title in /home/jj3wg2td/public_html/Careers Connect.php on line 19 Notice: Undefined index: Job Description in /home/jj3wg2td/public_html/Careers Connect.php on line 20 Notice: Undefined index: Salary Low in /home/jj3wg2td/public_html/Careers Connect.php on line 21 Notice: Undefined index: Salary High in /home/jj3wg2td/public_html/Careers Connect.php on line 22 Notice: Undefined index: Job Title in /home/jj3wg2td/public_html/Careers Connect.php on line 19 Notice: Undefined index: Job Description in /home/jj3wg2td/public_html/Careers Connect.php on line 20 Notice: Undefined index: Salary Low in /home/jj3wg2td/public_html/Careers Connect.php on line 21 Notice: Undefined index: Salary High in /home/jj3wg2td/public_html/Careers Connect.php on line 22
  12. and: Notice: Trying to get property of non-object in /home/jj3wg2td/public_html/Careers Connect.php on line 15
  13. Thought I may have solved it then: Changed Dreamweaver PHP version to 7.1 and MyPHP version in cPanel to be 7.1...but same error reported (Grrr)
  14. Thanks for your reply Steven...you cant imagine how grateful I am!!! Have altered the PHP code (below) on your advise, and have altered the headers in the database to be single words, like salaryLow, jobDescription to match the php: < <?php session_start(); $output=NULL; ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL); //Connect to the database $mysqli = new mysqli("localhost", "jj3wg2td_steven", "PASSWORD", "jj3wg2td_careerslist"); //Query the database if((isset($_POST['submit'])) && (isset($_POST['search']) && ($_POST['search'] != NULL))) { $search = $mysqli->real_escape_string($_POST['search']); $result = $mysqli->query("SELECT * FROM careers WHERE JobTitle regexp $search"); if($result->num_rows > 0) { while($rows=$result->fetch_assoc()) { $jobTitle=$rows['Job Title']; $jobDesription=$rows['Job Description']; $salaryLow=$rows['Salary Low']; $salaryHigh=$rows['Salary High']; $output .="Job Title: $jobTitle<br /> Job Description: $jobDesription<br /> Salary Low: $salaryLow<br /> Salary High: $salaryHigh<br /> <br />"; } } else{ $output="No results"; } } ?> > The error it is now coughing out is: Warning: mysqli::__construct(): Headers and client library minor version mismatch. Headers:50646 Library:50528 in /home/jj3wg2td/public_html/Careers Connect.php on line 8 Whilst this is all new to me, I believe this is now down to an issue with PHP version mismatch? Have built the PHP using Dreamweaver CC (v19.1) and have PHP Version 5.6 I cannot apologise enough for using up your time, but you are the first person to have made any leg room with this!! Kindest Steven
×
×
  • 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.