Jump to content

atticus

Members
  • Posts

    176
  • Joined

  • Last visited

Everything posted by atticus

  1. I get an undeclared object error if I simply include the config.php file in either the parent page or the functions.php page. This is the config.php script: $mysqli = new mysqli("***"); /* check connection */ if ($mysqli->connect_errno) { printf("Connect failed: %s\n", $mysqli->connect_error); exit(); } This is the functions page: include 'config.php'; function calls($duplicates) { if ($duplicates == 0) { if ($result = $mysqli->query("SELECT * FROM calls WHERE duration >= 30")) { printf("Select returned %d rows.\n", $result->num_rows); } else {printf ("Errormessage: %s\n", $mysqli->error); } $result->close(); } else { } } So, I have to move the config.php file into the function in order to execute the query. I know this is a noob question, but I am just learning object oriented. Thanks in advance.
  2. I don't know, but does MySQL need an additional " at the end of line 1?
  3. I know this must be a syntax error. This is the error: Errormessage: Unknown column 'thisiserror' in 'field list' Whatever variable I use in the URL for referrermedium is listed as the unknown column: call.php?duration=127&callsource=callsource&datetime=datetime&trackingnum=123&callernum=3433&destinationnum=destinationnum&recording=recording&callername=callername&keywords=keywords&referrer=referrer&referrermedium=thisiserror&landingpage=landingpage Code: <?php $callsource = $_GET['callsource']; $duration = $_GET['duration']; $datetime = $_GET['datetime']; $trackingnum = $_GET['trackingnum']; $callernum = $_GET['callernum']; $destinationnum = $_GET['destinationnum']; $recording = $_GET['recording']; $callername = $_GET['callername']; $keywords = $_GET['keywords']; $referrer = $_GET['referrer']; $referrermedium = $_GET['referrermedium']; $landingpage = $_GET['landingpage']; if ($mysqli->query("INSERT INTO calls (`callsource`, `duration`, `datetime`, `trackingnum`, `callernum`, `destinationnum`, `recording`, `callername`, `keywords`, `referrer`, `referrermedium`, `landingpage`) VALUES ($callsource, $duration, $datetime, $trackingnum, $callernum, $destinationnum, $recording, $callername, $keywords, $referrer, $referrermedium, $landingpage);") === TRUE) { printf("Item inserted\n"); } else {printf ("Errormessage: %s\n", $mysqli->error); } ?>
  4. You are right Pikachu2000, I wasn't inserting anything into the id column so I needed to list fields explicitly. Thanks man!
  5. The following query outputs rows: if ($result = $mysqli->query("SELECT option_name FROM wp_options LIMIT 10")) { printf("Select returned %d rows.\n", $result->num_rows); } This must be the troubled code: if ($mysqli->query("INSERT INTO leads_main VALUES('$service','$form','$confirmation','$special','$function')") === TRUE) { printf("data inserted.\n"); }
  6. I checked the connection with mysqli ping and it says its ok: /* check if server is alive */ if ($mysqli->ping()) { printf ("Our connection is ok!\n"); } else { printf ("Error: %s\n", $mysqli->error); }
  7. This code is not presenting error messages and is not inserting the data as expected. Anything I'm missing? ///DB Connection $mysqli = new mysqli("localhost", "***", "***", "***"); if ($mysqli->connect_errno) { echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error; } ////Hidden Form Information $service = $_GET['service']; $form = $_GET['form']; $confirmation = $_GET['confirmation']; $special = $_GET['special']; $function = $_GET['function']; ////Insert into DB and confirm if ($mysqli->query("INSERT INTO leads_main VALUES('$service','$form','$confirmation','$special','$function'") === TRUE) { printf("Table myCity successfully created.\n"); }
  8. I know that I am missing something simple, probably in my syntax. But I am getting a 500 server error instead of a PHP error. Not sure why Here is the total associative array query: $query = "SELECT address, zip, square_footage FROM person WHERE person_id = $id"; if ($result = $mysqli->query($query)) { /* fetch associative array */ while ($row = $result->fetch_assoc()) { $message .= '\n <strong>Square Footage: </strong>' .$row["square_footage"]; $message .= '\n <strong>Address </strong>' .$row["address"]; $message .= '\n <strong>Zip </strong>' .$row["zip"]); } /* free result set */ $result->free(); } If I remove the following three lines, I no longer get an error: $message .= '\n <strong>Square Footage: </strong>' .$row["square_footage"]; $message .= '\n <strong>Address </strong>' .$row["address"]; $message .= '\n <strong>Zip </strong>' .$row["zip"]);
  9. Okay, I feel like an idiot...should be using UPDATE instead of INSERT
  10. Should I be using a different error reporting method with mysqlli instead of "or die"?
  11. Name is Name on form. Echo $name confirms $_POST is working.
  12. I have verified all connection and table data is connect. I typically do not use mysqlli. What am I doing wrong: <?php error_reporting(E_ALL); ini_set('display_errors', '1'); $id = $_POST['id']; $name = $_POST['Name']; $email = $_POST['Email']; $phone = $_POST['Phone']; $city = $_POST['City']; echo $name; ////// Connect to DB $mysqli = new mysqli("db", "user", "pass", "db"); /* check connection */ if (mysqli_connect_errno()) { printf("Connect failed: %s\n", mysqli_connect_error()); exit(); } $query = "INSERT INTO person(name,email,phone,city) VALUES ('$name','$email','$phone','$city') WHERE person_id = $id" or die('Could not connect: ' . mysql_error()); $mysqli->query($query); ?>
  13. Distinct, of course! Dr. Qu would be shaking his head after spending countless hours trying to pump that db stuff in my head back in the day...thanks for pointing me in the right direction.
  14. Hi all, I want to put the data from MySQL into a regular array so that I can use array_unique to to remove duplicate data. I need all three variables to be associated with one index point. $months = array(); $i = 0; while($row = mysql_fetch_array($query)) { $monthname = $row['MONTHNAME(`time`)']; $year = $row['YEAR(`time`)']; $month = $row['MONTH(`time`)']; $months[] = ($i => $monthname,$year, $month); $i++;
  15. I am looking for documentation on what the -> means as in the following code: $user = json_decode(file_get_contents( 'https://graph.facebook.com/me?wrap_access_token=' . $cookie['oauth_access_token']))->me; register_user($user->id, $user->email, $user->name, $user->username, $user->birthday_date); I am not sure why I am having trouble grabbing the data in the variable.
  16. Alright, I recently made a domain name change. In the change I set up a 301 redirect for all traffic, including www and non www from old domain. However, I cannot seem to get the https://www.olddomain.com to redirect. Both domains are pointing at the same server and location. RewriteEngine On rewritecond %{http_host} ^yoursite.com rewriteRule ^(.*) http://www.yoursite.com/$1 [R=301,L]
  17. SEO is not "dark magic" or anything else spooky. All it takes it time and research to "reverse engineer" search rankings. On to molly's cannons. What is your site actually about? The single most important on page optimzation factor is the title tag. The single most important page on your site is your home page. Especially since the majority of the 1k backlinks you have are pointing to it. Currently your title tag only has Mollys Cannon and home. Do some keyword research around your subject and choose something you want to rank for and put it into your title tag with these tools: https://adwords.google.com/select/KeywordToolExternal http://freekeywords.wordtracker.com/ But you know the biggest issues your site has is duplicate content. It appears to me that you are featuring articles you like from other authors that appear somewhere first. Google filters out duplicate content. If you want the site ranked well, you need to be writing original content on a regular basis. Nice site design by the way. I like the overall readability of the site.
  18. You guys really know you stuff...and you actually answered my next question before I could even ask it. Thanks.
  19. Here is the regex: $regex = '~<p class="product-attr">(.+)</p>~'; This is what I am trying to grab: <p class="product-attr"> W/ features and more text to put into my variable </p>
  20. Should be: <span class="main-title">(.+)</span>
  21. Hi all. I am trying to parse HTML and grab a title from the text. Right now, I am getting just a blank page (error reporting is turned on) Here is the problem code: $regex = '~<span class="main-title">(?)</span>~'; preg_match_all($regex,$html,$match); foreach ($match[1] as $digit) { echo $digit; } Here is the complete function: function site($URL) { $target_url = "$URL"; $userAgent = 'User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.12) Gecko/20080201 Firefox/2.0.0.12\r\n'; // make the cURL request to $target_url $ch = curl_init(); curl_setopt($ch, CURLOPT_USERAGENT, $userAgent); curl_setopt($ch, CURLOPT_URL,$target_url); curl_setopt($ch, CURLOPT_FAILONERROR, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_AUTOREFERER, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER,true); curl_setopt($ch, CURLOPT_TIMEOUT, 10); $html= curl_exec($ch); if (!$html) { echo " cURL error number:" .curl_errno($ch); echo " cURL error:" . curl_error($ch); exit; } // parse the html into a DOMDocument // $dom = new DOMDocument(); // @$dom->loadHTML($html); //echo $html; $regex = '~<span class="main-title">(?)</span>~'; preg_match_all($regex,$html,$match); foreach ($match[1] as $digit) { echo $digit; } }
×
×
  • 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.