![]() |
![]() |
![]() |
||||
Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact us. |
![]() ![]() |
|
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed. |
|
Thread Tools |
![]() |
#51 |
see you later, I'm gone
Industry Role:
Join Date: Oct 2002
Posts: 14,057
|
Fiddy PHP Errors....
Just realized, you pull author into a field called random_tags but you never do use it any where. .
__________________
All cookies cleared! |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#52 | |
see you later, I'm gone
Industry Role:
Join Date: Oct 2002
Posts: 14,057
|
Quote:
the command is error_reporting(E_ALL); damn. .
__________________
All cookies cleared! |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#53 | |
Confirmed User
Industry Role:
Join Date: Oct 2018
Location: New Orleans, Louisiana. / Newcastle, England.
Posts: 1,123
|
Quote:
Playing with the code you posted now, shall report back in a little while, thank you again for your help with this php stuff, I really appreciate your time and assistance ![]() |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#54 |
see you later, I'm gone
Industry Role:
Join Date: Oct 2002
Posts: 14,057
|
A cleaner version. More my style. No camelcase shit ;p
<?php error_reporting(E_ALL); $id=0; if ( ! isset($_GET['id'] ) ) { header('Location: index.php'); } else { $id=intval($_GET['id']); } if($id==0) { die('bad id passed in'); } $pdo=hookitup(); $table = "recipes"; $sql = "select * from " . $table . " where id=?"; try { $stmt = $db->prepare($sql_str); $stmt->execute(array($pdo->quote($id))); } catch( PDOException $e) { die($e-getMessage()); } $row=$stmt->fetch(PDO::FETCH_ASSOC); $title = $row['recipename']; $description = $row['recipedescription']; ?> <html> <head> <base href="https://gfy.com/" /><!--[if IE]></base><![endif]--> <base href="https://gfy.com/" /><!--[if IE]></base><![endif]--> <base href="https://gfy.com/" /><!--[if IE]></base><![endif]--> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title><?php echo $title; ?> Recipe | Sitename</title> <meta name="Description" content="<?php echo $description; ?>"> <meta name="Keywords" content="<?php echo $title; ?> Recipe Ingredients Make <?php echo $title; ?> Recipes"> <link rel="stylesheet" href="style.css" type="text/css"/> <link rel="canonical" href="//siteurl/"> </head> <body class="home page page-id-21 page-template-default ie et_includes_sidebar"> <?php require_once('./templates/header.php'); ?> <div id="hd_logo0"> <p> <a href="http://www.domain.com"> <img class="alignnone size-full wp-image-169" alt="" src="logo.png" style="width: 310px"/> </a> </p> </div> <?php require_once('./templates/secondary.php'); ?> <center> <div id="main-area"> <div class="container" style="left: 0px; top: 0px"> <div id="content-area" class="clearfix"> <div id="left-area"> <div id="breadcrumbs" class="clearfix"> <a href="http://www.domain.com" class="breadcrumbs_home">Home</a> <span class="raquo">»</span> </div> <article id="post-21" class="post-21 page type-page status-publish hentry entry clearfix"> <div class="post_content clearfix"> <h1 class="title">Home</h1> <?php require_once('./templates/midbanner.php'); echo "<table>"; echo "<tr>"; echo "<td>" . $row['title'] . "</td>"; echo "<td>" . $row['ingredients'] . "</td>"; echo "<td>" . $row['method'] . "</td>"; echo "</tr>"; echo "</table>"; ?> </div> </article> </div> <?php require_once('./templates/sidebar.php'); ?> </div> </div> <!-- end .container --> </div> <!-- end #main-area --></center> <?php require_once('./templates/footer.php'); ?> <script type="text/javascript" src="jquery.form.min.js"></script> <script type="text/javascript" src="superfish.js"></script> <script type="text/javascript" src="jquery.fitvids.js"></script> <script type="text/javascript" src="custom.js"></script> </body> </html> <?php function hookitup() { require_once('dbcreds.php'); return new PDO("mysql:host=$host;dbname=$dbname;charset=utf8" ,$user,$password,array(PDO::ATTR_EMULATE_PREPARES => false, PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION)); } In dbcreds.php would be: <?php $dbname='dbname'; $dbuser='dbusername'; $dbpass='dbpassword'; $dbhost='localhost'; ?> .
__________________
All cookies cleared! |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#55 |
Confirmed User
Industry Role:
Join Date: Sep 2013
Location: The Netherlands
Posts: 805
|
A small addition to the code above:
$title = ucwords($row['recipename']); //Personal taste, but I like titles like that. The above makes each first character of a word uppercase: This Is A Great Title $description = ucfirst($row['recipedescription']); //Makes the first character of your string uppercase (in case it isn't stored that way in the database. It looks pretty bad in the search results if your description's first letter isn't uppercase. |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#56 |
Confirmed User
Industry Role:
Join Date: Oct 2018
Location: New Orleans, Louisiana. / Newcastle, England.
Posts: 1,123
|
Apologies for the late response, we lost power again last night while they were working on the lines to try and get the rest of the neighborhood up and running.
I played with the code you posted and seem to be getting a weird error where the data from the SQL isn't showing, its just giving me a blank page and there are no meta tags showing up either. (Didn't change anything until after the blank page showed). Putting back the original code, the page works how it is supposed to, any thoughts? ![]() |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#57 |
Confirmed User
Join Date: Feb 2009
Posts: 201
|
Code:
$sql = "select * from " . $table . " where id=?"; try { $stmt = $db->prepare($sql_str); |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#58 | ||
Confirmed User
Industry Role:
Join Date: Oct 2018
Location: New Orleans, Louisiana. / Newcastle, England.
Posts: 1,123
|
Quote:
I gave that a try and its still showing a blank page, this is the error from the logs: Quote:
|
||
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#59 | |
Confirmed User
Industry Role:
Join Date: Sep 2013
Location: The Netherlands
Posts: 805
|
Quote:
{ require_once('dbcreds.php'); return new PDO("mysql:host=$host;dbname=$dbname;charset=utf8" ,$user,$password,array(PDO::ATTR_EMULATE_PREPARES => false, PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION)); } dbcreds file: <?php $dbname='dbname'; $dbuser='dbusername'; $dbpass='dbpassword'; $dbhost='localhost'; ?> These two don't match, that's why you're getting a blank page (as no database connection is being made). Change the function to: function hookitup() { require_once('dbcreds.php'); return new PDO("mysql:host=$dbhost;dbname=$dbname;charset=utf8" ,$user,$password,array(PDO::ATTR_EMULATE_PREPARES => false, PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION)); } And as K33n noted, change: $stmt = $db->prepare($sql_str); to: $stmt = $db->prepare($sql); |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#60 |
Confirmed User
Industry Role:
Join Date: Sep 2013
Location: The Netherlands
Posts: 805
|
To OP: You can learn a lot from looking more closely to your error log. This one was easy to spot.
Your error: #0 /blah/blah/domain.com/recipesnew.php(119): PDO->__construct('mysql:host=;dbn...', NULL, NULL, Array) See how host= is empty... |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#61 | ||
Confirmed User
Industry Role:
Join Date: Oct 2018
Location: New Orleans, Louisiana. / Newcastle, England.
Posts: 1,123
|
Quote:
Its still not showing anything BUT, does that mean I also need to make the following changes based on this error? Quote:
} Or am I looking in the wrong place/overthinking and doing the wrong thing? |
||
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#63 |
see you later, I'm gone
Industry Role:
Join Date: Oct 2002
Posts: 14,057
|
Sorry about that. I didn't do a full test and that kind of shit happens when you meld 2 different sets of code together.
In this case, I grabbed my dbcreds file from my local machine and my hookup routine from a different place. But that is what debugging is for, ya know? I really didn't think you were just going to switch out to the new code I posted, I was just trying to get to a code set that made sense to me. .
__________________
All cookies cleared! |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#64 | |
Confirmed User
Industry Role:
Join Date: Oct 2018
Location: New Orleans, Louisiana. / Newcastle, England.
Posts: 1,123
|
I'm still missing something though as its giving a 500 error.
Quote:
![]() |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#65 | |
see you later, I'm gone
Industry Role:
Join Date: Oct 2002
Posts: 14,057
|
Quote:
From the error you posted it appears that you do not have anything populated into your $dbuser and $dbpass variables. But post line 118 of the program, please. .
__________________
All cookies cleared! |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#66 | |
Confirmed User
Industry Role:
Join Date: Oct 2018
Location: New Orleans, Louisiana. / Newcastle, England.
Posts: 1,123
|
Quote:
![]() I'm really appreciative of everyone's help, assistance and knowledge in this thread as I'm sure you all have other things you could be doing instead of sharing your expertise. |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#67 | |
Confirmed User
Industry Role:
Join Date: Oct 2018
Location: New Orleans, Louisiana. / Newcastle, England.
Posts: 1,123
|
Line 118 in recipesnew.php is:
Quote:
|
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#68 | |
Confirmed User
Industry Role:
Join Date: Sep 2013
Location: The Netherlands
Posts: 805
|
Quote:
![]() ![]() By the way, I think you can even shorten this: $id=0; if ( ! isset($_GET['id'] ) ) { header('Location: index.php'); } else { $id=intval($_GET['id']); } if($id==0) { die('bad id passed in'); } Into: $id=intval($_GET['id']); if($id==0) { header( "Location: index.php" ); //or any other page like 404 exit; } As intval will also output 0 if $id is empty. |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#69 | |
see you later, I'm gone
Industry Role:
Join Date: Oct 2002
Posts: 14,057
|
Quote:
indicates that you are not passing in a username or password. The places that say NULL, NULL right before the Array indicate that $dbuser and $dbpass are coming in as NULL meaning there ain't nothing there. Your error: /blah/blah/domain.com/recipesnew.php(118): PDO->__construct('mysql:host=loca...', NULL, NULL, Array) PDO("mysql:host=$dbhost;dbname=$dbname" ,$dbuser,$dbpass,array(PDO::ATTR_EMULATE_PREPARES => false, PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION)); } So, if you are using the dbcreds.php file then the problem is in there. If you are not using that and have the user and password hardcoded then that would be where the issue is. The charset=utf8 just tells it to accept utf8 characters. The routine I pulled it from has to handle various different languages. I pretty much have everything I do coded for utf8 (unicode). .
__________________
All cookies cleared! |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#70 | |
see you later, I'm gone
Industry Role:
Join Date: Oct 2002
Posts: 14,057
|
Quote:
I tend to, when trying to do code 101 stuff use old old school. First step intialize variable to default value then use it. But yeah you are initializing it to whatever comes into the get if it is a valid int or zero if not so it does the same thing in a couple of less words. .
__________________
All cookies cleared! |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#71 | |||||
Confirmed User
Industry Role:
Join Date: Oct 2018
Location: New Orleans, Louisiana. / Newcastle, England.
Posts: 1,123
|
Quote:
Quote:
This is the dbcreds.php file that is being used: Quote:
Quote:
Quote:
![]() |
|||||
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#72 |
see you later, I'm gone
Industry Role:
Join Date: Oct 2002
Posts: 14,057
|
The code you are posting looks right The bottom part you posted at the end where you moved the quote marks is wrong.
The part of the error you are showing us indicated that there is nothing in the username and password variables which would mean the problem is in the dbcreds.php like I said earlier. I have sent you a pm. .
__________________
All cookies cleared! |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#73 |
see you later, I'm gone
Industry Role:
Join Date: Oct 2002
Posts: 14,057
|
I sent this via pm also but
in the dbcreds.php you are missing a semicolon after localhost $dbhost='localhost' Should be $dbhost='localhost'; .
__________________
All cookies cleared! |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#74 |
see you later, I'm gone
Industry Role:
Join Date: Oct 2002
Posts: 14,057
|
In the code you sent me:
return new PDO("mysql:host=$dbhost;dbname=$dbname;charset=utf 8" ,dbuser=$dbuser;dbpass=$dbpass,array(PDO::ATTR_EMULATE_PREPARES => false, PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION)); should be: return new PDO("mysql:host=$dbhost;dbname=$dbname;charset=utf 8",$dbuser,$dbpass,array(PDO::ATTR_EMULATE_PREPARES => false, PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION)); You added an equals sign in the dbuser and dbpass that should not be there. There is still an issue in the code. I am looking. .
__________________
All cookies cleared! |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#75 |
see you later, I'm gone
Industry Role:
Join Date: Oct 2002
Posts: 14,057
|
On line 15-17 you have a try statement that is not completed:
try { $sql = "select * from " . $table . " where id=?"; Get rid of that. .
__________________
All cookies cleared! |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#76 |
see you later, I'm gone
Industry Role:
Join Date: Oct 2002
Posts: 14,057
|
A mistake in the code I posted.
around line 16: try { $stmt = $db->prepare($sql); } catch( PDOException $e) { die($e-getMessage()); } should be: try { $stmt = $pdo->prepare($sql); } catch( PDOException $e) { die($e-getMessage()); } .
__________________
All cookies cleared! |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#77 |
see you later, I'm gone
Industry Role:
Join Date: Oct 2002
Posts: 14,057
|
Damn I suck today
![]() Another issue in what I posted: try { $stmt = $pdo->prepare($sql); } catch( PDOException $e) { die($e-getMessage()); } Should be: try { $stmt = $pdo->prepare($sql); } catch( PDOException $e) { die($e->getMessage()); } .
__________________
All cookies cleared! |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#78 |
see you later, I'm gone
Industry Role:
Join Date: Oct 2002
Posts: 14,057
|
Also, (this one is not my mistake) you removed the execute statement from that same code block.
So: try { $stmt = $pdo->prepare($sql); } catch( PDOException $e) { die($e->getMessage()); } Should be: try { $stmt = $pdo->prepare($sql); $stmt->execute(array($pdo->quote($id))); } catch( PDOException $e) { die($e->getMessage()); }
__________________
All cookies cleared! |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#79 |
see you later, I'm gone
Industry Role:
Join Date: Oct 2002
Posts: 14,057
|
Well, that was fun.
To whoever was watching, the OP and I took it private so I could see the actual code without revealing any proprietary info. It looks like he is in pretty good shape now. It was mainly syntax issues. .
__________________
All cookies cleared! |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#80 |
Confirmed User
Industry Role:
Join Date: Oct 2018
Location: New Orleans, Louisiana. / Newcastle, England.
Posts: 1,123
|
sarettah,
I just want to say thank you for all of your help, not only in this thread over the past week but also by PM, you truly do not know how appreciative I am of your time helping me to get this pet project working, I'm sure there are a hundred other things you could have been doing this afternoon instead of spending time to get this working for me. I'm going to play around with a couple of other formatting issues that I'm having but other than that, I am really happy with how this site has turned out, even though its just a pet project of mine and not really going to be a money maker its good to start seeing it come to fruition ![]() Thank you so much ![]() |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#81 |
see you later, I'm gone
Industry Role:
Join Date: Oct 2002
Posts: 14,057
|
No problem. You are welcome.
.
__________________
All cookies cleared! |
![]() |
![]() ![]() ![]() ![]() ![]() |