Jump to content

gizmola

Administrators
  • Content Count

    4,867
  • Joined

  • Last visited

  • Days Won

    43

gizmola last won the day on May 22

gizmola had the most liked content!

Community Reputation

158 Excellent

1 Follower

About gizmola

  • Rank
    Prolific Member

Contact Methods

  • AIM
    gizmoitus
  • Website URL
    http://www.gizmola.com/

Profile Information

  • Gender
    Male
  • Location
    Los Angeles, CA USA

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. __repr__ is a special class function named as a shortend version of "representation", that is essentially a to_string equivalent. It gets called when you try to use an object as if it was a string as well as in some other situations where you want a representation of the object rather than the object itself. For example, if you execute: my_pizza = Pizza(["onions", "peppers"]) print(my_pizza) WIthout a __repr__ or __str__ class function, Python will just print information about the object. With the __repr__ by convention, the goal is to return an unambiguous representation of the object in a way that the result would be valid Python which could be run again as Python code. This is why the __repr__ is returning Because that is how the object was created. There are not 3 arguments. There is one argument to the constructor (not including the implicit self), but that argument can be any valid Python type. In the example, the parameter being passed is a list. I would assume to help teach you about the repr magic method. Other types of methods whether static or instance methods have to be explicitly called. Magic methods are called auto "magically" by Python when it's appropriate.
  2. The terminology you are using is a little odd. Servers don't "listen" to directories. Directories are either in web space or not. It looks to me like the only folder you want to be in "web space" is the public directory. Is your web root /public or are all the directories beneath the web root? There are many background questions that might help shed some light including: What web server is this running under? Apache? Nginx? Some of this info can be obtained from a quick script in the public directory that just contains phpinfo() What is in the composer.json, and in particular, the autoload configuration? What is in the .htaccess? What is in the index.php? Is this a framework project (CakePHP maybe?) When you say that this is shared hosting, does that mean that you don't have a shell and just ftp'd the site from your development box? Are you able to run composer install on the host? At the end of the day, there has to be something in a log that tells you what the error is. Where are the error logs for the site?
  3. Correct. Because it's a numeric array, when you do foreach($key => $value) the array key is going to be either an "associative" key ie some string like 'title', or it will just be numeric. Other languages often have completely different data structures for these things like array vs. map, but one of the really nice features of PHP is that they intermix the two. Since the array I was foreaching through was numeric, the first element will be 0. PHP is the same as most other languages (c, c++, javascript, c#, java) in that the first element of an array will be indexed at 0. ++ is the increment operator, so it just adds 1 to the value. Thus you get things numbered starting at 1. If you want a different numbering system, I would actually recommend not using your own numbering at all, but instead emit an html ordered list, and use css to style the list for you.
  4. The reason things are jumbled is because the output was set for command line php. If you run this as a script via a webserver, then you will be outputting html and you would need to add the desired html. Just to get a quick look at it, you can add pre tags around it. Anything else would be a tutorial in html and I have to assume you can do that on your own. echo "<pre>"; foreach($json['data'] as $data) { echo "Title: {$data['title']}\n"; echo "Event Time: {$data['live_event']['start_time']}\n"; echo "Streams:\n"; foreach($data['live_event']['stream_list'] as $i => $stream) { $i++; echo " $i. {$stream['stream_id']}\n"; } echo "\n"; } echo "</pre>"; As for format of the number, the important thing is that you read my code and figure out why it does what it does. Then changing the way the number looks should be easy. As for the date/time, I just used what you were using, but it looks like if you want a Datetime value, you should use $data['live_event']['start_at'] instead of start_time. In order to change the format you might need to look into the php DateTime Class.
  5. This is what I was looking for: $jsondata = file_get_contents("https://kalebdf.com/flo/api.php?url=events%2Fnow-and-upcoming%3Flimit%3D70%26tz%3DAmerica%2FNew_York%26live_only%3D1%26site_id%3D1%252C2%252C3%252C4%252C5%252C6%252C7%252C8%252C9%252C10%252C11%252C12%252C13%252C14%252C15%252C16%252C17%252C18%252C19%252C20%252C21%252C22%252C23%252C24%252C25%252C26%252C27%252C28%252C29%252C30%252C31%252C32%252C33%252C34%252C35%252C36%252C37%252C38%252C39%252C41%252C43"); $json = json_decode($jsondata, true); var_dump($json['data']); Now that we can see your source json, this is obviously a huge result. I'm not sure that turning this into a gigantic array is helpful because it's such a large json data structure with many keys. However, in general you can determine what is going to happen based on whether the json has an array structure ie [ ] or a property "somename": "some_value" The original json has many of these properties. If something is inside a json array, then it will be turned into a numerically indexed array: $var[0], $var[1] etc. Unless you know which specific array element you need, typically you're going to foreach() loop through them. If the original json is a property then the property name is going to be turned into an array key, with the associated value stored in the array element. That value could be a nested object: { }, a single value, or an array. And in each case there is possible nesting. If you understand the basics of this, you should be able to look at the original json and figure out how it will be converted. In your case, when we var_dump($json['data']) the top level is revealed to be a giant numerically indexed array: You are foreach()ing through this array. So to get an idea of what just one looks like, it's helpful to var_dump the first one: var_dump($json['data'][0]); This shows the nested structure for each array element you'll get when you foreach through the outer structure: array(41) { ["id"]=> int(6251309) ["should_show_read_more"]=> bool(true) ["ad_set_code"]=> NULL ["slug_uri"]=> string(33) "/events/6251309-2019-giro-ditalia" ["title"]=> string(18) "2019 Giro d'Italia" ["short_title"]=> string(13) "Giro d'Italia" ["seo_description"]=> string(122) "Tune in to FloBikes for complete editorial coverage and to watch every stage of the 2019 Giro d'Italia live and on demand!" ["author"]=> array(10) { ["profile_picture_url_small"]=> string(86) "https://res.cloudinary.com/diznifoln/image/upload/w_100,h_100/oz7rkl8ihbds5yb20ujn.png" ["profile_picture_url_medium"]=> string(86) "https://res.cloudinary.com/diznifoln/image/upload/w_125,h_125/oz7rkl8ihbds5yb20ujn.png" ["profile_picture_url_large"]=> string(86) "https://res.cloudinary.com/diznifoln/image/upload/w_150,h_150/oz7rkl8ihbds5yb20ujn.png" ["id"]=> int(1625830) ["username"]=> string(10) "JoeBatts75" ["first_name"]=> string(3) "Joe" ["last_name"]=> string(9) "Battaglia" ["gender"]=> string(1) "m" ["created_at"]=> string(24) "2014-04-10T14:03:26+0000" ["modified_at"]=> string(24) "2019-02-04T16:24:23+0000" } ["asset"]=> array(14) { ["id"]=> int(6456733) ["title"]=> string(53) "El-Giro-de-Italia-2018-comenzará-en-Jerusalén.jpg" ["description"]=> NULL ["credit"]=> NULL ["source"]=> string(71) "//flo30-assets-prod.s3.amazonaws.com/uploads/FloBikes/5ba8fda8b17eb.png" ["site"]=> array(13) { ["domain"]=> string(16) "www.flobikes.com" ["id"]=> int(37) ["name"]=> string(8) "FloBikes" ["code"]=> string(8) "flobikes" ["host"]=> string(23) "http://www.flobikes.com" ["active"]=> bool(true) ["type"]=> string(4) "site" ["version"]=> int(3) ["color"]=> string(7) "#FF8200" ["hero_image"]=> string(86) "https://d6fm3yzmawlcs.cloudfront.net/mobileVerticalBackground/mobile_bg_flocycling.jpg" ["modified_at"]=> NULL ["show_on_mobile"]=> bool(true) ["sport_name"]=> string(7) "Cycling" } ["url"]=> string(55) "https://d2779tscntxxsw.cloudfront.net/5ba8fda8b17eb.png" ["library"]=> bool(true) ["status_code"]=> int(200) ["path"]=> string(77) "https://flo30-assets-prod.s3.amazonaws.com/uploads/FloBikes/5ba8fda8b17eb.png" ["copied"]=> bool(true) ["duplicated"]=> bool(false) ["created_at"]=> string(24) "2018-09-24T15:07:21+0000" ["modified_at"]=> string(24) "2018-10-13T08:09:22+0000" } ["logo"]=> NULL ["slug"]=> string(17) "2019-giro-ditalia" ["publish_start_date"]=> string(24) "2018-09-24T15:26:00+0000" ["publish_end_date"]=> NULL ["status"]=> int(1) ["status_text"]=> string(18) "Active - Published" ["status_color"]=> string(7) "#CDEB8B" ["premium"]=> bool(false) ["node"]=> array(13) { ["categories"]=> array(3) { [0]=> array(5) { ["id"]=> int(605) ["name"]=> string(4) "Road" ["parent"]=> array(5) { ["id"]=> int(602) ["name"]=> string(10) "Discipline" ["parent"]=> NULL ["created_at"]=> string(24) "2018-02-02T17:47:21+0000" ["modified_at"]=> NULL } ["created_at"]=> string(24) "2018-02-02T17:47:34+0000" ["modified_at"]=> NULL } [1]=> array(5) { ["id"]=> int(612) ["name"]=> string(12) "Professional" ["parent"]=> array(5) { ["id"]=> int(603) ["name"]=> string(11) "Rider Level" ["parent"]=> NULL ["created_at"]=> string(24) "2018-02-02T17:47:21+0000" ["modified_at"]=> NULL } ["created_at"]=> string(24) "2018-02-02T17:47:53+0000" ["modified_at"]=> NULL } [2]=> array(5) { ["id"]=> int(621) ["name"]=> string(8) "UCI 2.WT" ["parent"]=> array(5) { ["id"]=> int(604) ["name"]=> string(10) "Race Level" ["parent"]=> NULL ["created_at"]=> string(24) "2018-02-02T17:47:21+0000" ["modified_at"]=> NULL } ["created_at"]=> string(24) "2018-02-02T17:48:48+0000" ["modified_at"]=> NULL } } ["primary_event_association"]=> NULL ["primary_event_or_series_association"]=> NULL ["people"]=> array(0) { } ["teams"]=> array(0) { } ["id"]=> int(6251309) ["current_revision"]=> NULL ["site"]=> array(13) { ["domain"]=> string(16) "www.flobikes.com" ["id"]=> int(37) ["name"]=> string(8) "FloBikes" ["code"]=> string(8) "flobikes" ["host"]=> string(23) "http://www.flobikes.com" ["active"]=> bool(true) ["type"]=> string(4) "site" ["version"]=> int(3) ["color"]=> string(7) "#FF8200" ["hero_image"]=> string(86) "https://d6fm3yzmawlcs.cloudfront.net/mobileVerticalBackground/mobile_bg_flocycling.jpg" ["modified_at"]=> NULL ["show_on_mobile"]=> bool(true) ["sport_name"]=> string(7) "Cycling" } ["view_count"]=> int(100740) ["legacy_id"]=> NULL ["search_indexed_at"]=> string(24) "2019-05-22T12:13:40+0000" ["created_at"]=> string(24) "2018-09-24T15:27:50+0000" ["modified_at"]=> string(24) "2019-05-22T12:13:40+0000" } ["enable_interstitial_ad"]=> bool(true) ["enable_pre_roll_ads"]=> bool(true) ["shareable_link"]=> string(57) "https://www.flobikes.com/events/6251309-2019-giro-ditalia" ["created_at"]=> string(24) "2018-09-24T15:27:50+0000" ["modified_at"]=> string(24) "2019-05-22T12:04:37+0000" ["has_schedule"]=> bool(true) ["preview_text"]=> string(217) "<p>The 2019 Giro d’Italia is a UCI World Tour event. Tune in to FloBikes for a complete editorial coverage and to watch every stage of the 2019 Giro d'Italia live and on demand, available in the U.S. and Canada.</p>" ["description"]=> string(225) "<p>The 2019 Giro d&rsquo;Italia is a UCI World Tour event. Tune in to FloBikes for a complete editorial coverage and to watch every stage of the 2019 Giro d&#39;Italia live and on demand, available in the U.S. and Canada.</p>" ["city"]=> string(7) "Bologna" ["region"]=> NULL ["country"]=> string(2) "IT" ["venue"]=> NULL ["start_date"]=> string(10) "2019-05-11" ["end_date"]=> string(10) "2019-06-02" ["schedule_tab_label"]=> string(8) "Schedule" ["participant_tab_label"]=> string(7) "Entries" ["live_updates_tab_label"]=> string(12) "Live Updates" ["info_tab_label"]=> string(4) "Info" ["live_event"]=> array(33) { ["event_ids"]=> array(1) { [0]=> int(6251309) } ["start_at"]=> string(20) "2019-05-22T11:05:00Z" ["end_at"]=> string(20) "2019-06-03T03:59:59Z" ["id"]=> int(8778) ["title"]=> string(18) "2019 Giro d'Italia" ["short_title"]=> string(13) "Giro D'Italia" ["stream1"]=> string(26) "cyp8778_2019_giro_d_italia" ["stream2"]=> string(26) "cyp8778_2019_giro_d_italia" ["stream_list"]=> array(2) { [0]=> array(7) { ["stream_id"]=> int(18633) ["stream_name"]=> string(18) "2019 Giro d'Italia" ["stream_code"]=> string(26) "cyp8778_2019_giro_d_italia" ["stream_active"]=> bool(true) ["stream_hls"]=> string(68) "http://flocasts-hls.videocdn.scaleengine.net/flocasts-florigins/play" ["stream_type"]=> string(8) "multiple" ["stream_mode"]=> string(6) "normal" } [1]=> array(7) { ["stream_id"]=> int(25651) ["stream_name"]=> string(13) "Giro d'Italia" ["stream_code"]=> string(21) "cyp8778_giro_d_italia" ["stream_active"]=> bool(false) ["stream_hls"]=> string(68) "http://flocasts-hls.videocdn.scaleengine.net/flocasts-florigins/play" ["stream_type"]=> string(8) "multiple" ["stream_mode"]=> string(6) "normal" } } ["slug"]=> string(18) "2019-giro-d-italia" ["description"]=> string(79) "<p> <span style="background-color: initial;">2019 Giro d'Italia</span> </p>" ["premium"]=> bool(true) ["ppv"]=> bool(false) ["disable_bumping"]=> bool(false) ["disable_login"]=> bool(false) ["enable_ott"]=> bool(true) ["status"]=> string(4) "LIVE" ["status_message"]=> NULL ["type"]=> string(6) "STREAM" ["start_date"]=> string(10) "2019-05-22" ["end_date"]=> string(10) "2019-06-02" ["start_time"]=> string(8) "07:05:00" ["end_time"]=> string(8) "23:59:59" ["timezone"]=> string(16) "America/New_York" ["start_date_time"]=> string(24) "2019-05-22T11:05:00+0000" ["end_date_time"]=> string(24) "2019-06-03T03:59:59+0000" ["start_at_next"]=> string(24) "2019-05-22T11:05:00+0000" ["background_url"]=> NULL ["live_event_url"]=> string(34) "https://www.flobikes.com/live/8778" ["player_version"]=> string(3) "3.0" ["dvr"]=> bool(false) ["created_at"]=> string(24) "2019-05-22T12:04:56+0000" ["modified_at"]=> string(24) "2019-05-22T12:04:56+0000" } ["watchable"]=> bool(true) ["replay_video_count"]=> int(10) ["replay_preview_vod"]=> NULL ["type"]=> string(5) "event" } Sometimes it's useful in such a large structure just to see the list of top level array keys. PHP has a helpful array_keys() function for this. Also, print_r has a slightly different output format from var_dump that omits the variable types. Just to get some clarity, I ran this: $json = json_decode($jsondata, true); $t = array_keys($json['data'][0]); sort($t); print_r($t); And got this output: Array ( [0] => ad_set_code [1] => asset [2] => author [3] => city [4] => country [5] => created_at [6] => description [7] => enable_interstitial_ad [8] => enable_pre_roll_ads [9] => end_date [10] => has_schedule [11] => id [12] => info_tab_label [13] => live_event [14] => live_updates_tab_label [15] => logo [16] => modified_at [17] => node [18] => participant_tab_label [19] => premium [20] => preview_text [21] => publish_end_date [22] => publish_start_date [23] => region [24] => replay_preview_vod [25] => replay_video_count [26] => schedule_tab_label [27] => seo_description [28] => shareable_link [29] => short_title [30] => should_show_read_more [31] => slug [32] => slug_uri [33] => start_date [34] => status [35] => status_color [36] => status_text [37] => title [38] => type [39] => venue [40] => watchable ) You had determined previously that the 2 top level elements you were interested in were 'title' and 'live_event'. 'title' is a single value, however live_event is another nested structure. To figure out what that looks like: var_dump($json['data'][0]['live_event']); And you get: array(33) { ["event_ids"]=> array(1) { [0]=> int(6251309) } ["start_at"]=> string(20) "2019-05-22T11:05:00Z" ["end_at"]=> string(20) "2019-06-03T03:59:59Z" ["id"]=> int(8778) ["title"]=> string(18) "2019 Giro d'Italia" ["short_title"]=> string(13) "Giro D'Italia" ["stream1"]=> string(26) "cyp8778_2019_giro_d_italia" ["stream2"]=> string(26) "cyp8778_2019_giro_d_italia" ["stream_list"]=> array(2) { [0]=> array(7) { ["stream_id"]=> int(18633) ["stream_name"]=> string(18) "2019 Giro d'Italia" ["stream_code"]=> string(26) "cyp8778_2019_giro_d_italia" ["stream_active"]=> bool(true) ["stream_hls"]=> string(68) "http://flocasts-hls.videocdn.scaleengine.net/flocasts-florigins/play" ["stream_type"]=> string(8) "multiple" ["stream_mode"]=> string(6) "normal" } [1]=> array(7) { ["stream_id"]=> int(25651) ["stream_name"]=> string(13) "Giro d'Italia" ["stream_code"]=> string(21) "cyp8778_giro_d_italia" ["stream_active"]=> bool(false) ["stream_hls"]=> string(68) "http://flocasts-hls.videocdn.scaleengine.net/flocasts-florigins/play" ["stream_type"]=> string(8) "multiple" ["stream_mode"]=> string(6) "normal" } } ["slug"]=> string(18) "2019-giro-d-italia" ["description"]=> string(79) "<p> <span style="background-color: initial;">2019 Giro d'Italia</span> </p>" ["premium"]=> bool(true) ["ppv"]=> bool(false) ["disable_bumping"]=> bool(false) ["disable_login"]=> bool(false) ["enable_ott"]=> bool(true) ["status"]=> string(4) "LIVE" ["status_message"]=> NULL ["type"]=> string(6) "STREAM" ["start_date"]=> string(10) "2019-05-22" ["end_date"]=> string(10) "2019-06-02" ["start_time"]=> string(8) "07:05:00" ["end_time"]=> string(8) "23:59:59" ["timezone"]=> string(16) "America/New_York" ["start_date_time"]=> string(24) "2019-05-22T11:05:00+0000" ["end_date_time"]=> string(24) "2019-06-03T03:59:59+0000" ["start_at_next"]=> string(24) "2019-05-22T11:05:00+0000" ["background_url"]=> NULL ["live_event_url"]=> string(34) "https://www.flobikes.com/live/8778" ["player_version"]=> string(3) "3.0" ["dvr"]=> bool(false) ["created_at"]=> string(24) "2019-05-22T12:04:56+0000" ["modified_at"]=> string(24) "2019-05-22T12:04:56+0000" } So finally we can see, that 'stream_list' is the key for an array of streams. Being that this is a numerically indexed array of 1..n items, you need to do a nested foreach() to iterate through the internal array elements. You've stated that you are only interested in the 'stream_id' element. So hopefully at this point, you can understand that you have an outer foreach() through the data elements, and then the requirement to do an inner foreach to get the individual stream_id elements from stream_list. <?php $jsondata = file_get_contents("https://kalebdf.com/flo/api.php?url=events%2Fnow-and-upcoming%3Flimit%3D70%26tz%3DAmerica%2FNew_York%26live_only%3D1%26site_id%3D1%252C2%252C3%252C4%252C5%252C6%252C7%252C8%252C9%252C10%252C11%252C12%252C13%252C14%252C15%252C16%252C17%252C18%252C19%252C20%252C21%252C22%252C23%252C24%252C25%252C26%252C27%252C28%252C29%252C30%252C31%252C32%252C33%252C34%252C35%252C36%252C37%252C38%252C39%252C41%252C43"); $json = json_decode($jsondata, true); foreach($json['data'] as $data) { echo "Title: {$data['title']}\n"; echo "Event Time: {$data['live_event']['start_time']}\n"; echo "Streams:\n"; foreach($data['live_event']['stream_list'] as $i => $stream) { $i++; echo " $i. {$stream['stream_id']}\n"; } echo "\n"; } Output: Title: 2019 Giro d'Italia Event Time: 07:05:00 Streams: 1. 18633 2. 25651 Title: 2019 Japan vs United States | Women's VNL Event Time: 08:45:00 Streams: 1. 24691 Title: 2019 Serbia vs Korea | Women's VNL Event Time: 09:45:00 Streams: 1. 24692 Title: 2019 Thailand vs Italy | Women's VNL Event Time: 10:15:00 Streams: 1. 24695 Title: 2019 Brose Bamberg vs Rasta Vechta | easyCredit BBL Event Time: 12:00:00 Streams: 1. 25885 Title: 2019 Bulgaria vs Belgium | Women's VNL Event Time: 12:15:00 Streams: 1. 24697 Title: 2019 Netherlands vs Turkey | Women's VNL Event Time: 12:45:00 Streams: 1. 24698 Title: 2019 Poland vs Germany | Women's VNL Event Time: 13:15:00 Streams: 1. 24699 Title: 2019 Kirolbet Baskonia vs Divinas Seguros Joventut | 2018-19 La Liga BB Event Time: 13:30:00 Streams: 1. 24555 Title: Here's The Deal Event Time: 14:30:00 Streams: 1. 17181 Title: 2019 China vs Russia | Women's VNL Event Time: 14:45:00 Streams: 1. 24700 Title: 2019 TSSAA Outdoor Championships Event Time: 17:00:00 Streams: 1. 23950 Title: Going Brooklyn: In Studio With Bowling's Big Names Event Time: 16:00:00 Streams: 1. 19566 Title: 2019 USAC Sprints at Terre Haute Action Track Event Time: 17:30:00 Streams: 1. 20891 2. 21547 3. 21850 Title: 2019 Brazil vs Dominican Republic | Women's VNL Event Time: 17:45:00 Streams: 1. 24701 Title: 2019 D.C. United vs Real Betis Event Time: 18:45:00 Streams: 1. 25324 2. 25961 Title: 2019 Sassari City Matteo Pellicone Memorial Event Time: 03:00:00 Streams: 1. 22004 Title: 2019 Canadian Gymnastics Championships - Artistic Event Time: 08:30:00 Streams: 1. 22977 Title: 2019 Belgium vs Japan | Women's VNL Event Time: 08:45:00 Streams: 1. 24702 Title: 2019 CAN vs SUI | IIHF World Quarterfinals Event Time: 09:15:00 Streams: 1. 25647 2. 25958 Title: 2019 Netherlands vs Korea | Women's VNL Event Time: 09:45:00 Streams: 1. 24703 Title: 2019 Italy vs Germany | Women's VNL Event Time: 10:15:00 Streams: 1. 24704 Title: FloTrack TV Event Time: 12:00:00 Streams: 1. 24624 Title: 2019 United States vs Bulgaria | Women's VNL Event Time: 12:15:00 Streams: 1. 24705 Title: 2019 Turkey vs Serbia | Women's VNL Event Time: 12:45:00 Streams: 1. 24706 Title: 2019 Thailand vs Poland | Women's VNL Event Time: 13:15:00 Streams: 1. 24707 Title: 2019 CZE vs GER | IIHF World QuarterFinals Event Time: 13:15:00 Streams: 1. 25959 Title: 2019 DI NCAA West Preliminary Round Event Time: 12:00:00 Streams: 1. 23835 2. 25953 Title: 2019 DI NCAA East Preliminary Round Event Time: 15:30:00 Streams: 1. 23834 2. 25954 Title: 2019 China vs Dominican Republic | Women's VNL Event Time: 14:45:00 Streams: 1. 24708 Title: 2019 MPSSAA Outdoor Championships Event Time: 16:00:00 Streams: 1. 24005 Title: 2019 NHSRA Louisiana State Finals: RidePass PRO Event Time: 15:15:00 Streams: 1. 25111 etc.
  6. FYI I answered you in irc. We need a print_r or var_dump of the structure in order to understand the array structure, as do you.
  7. gizmola

    Query needed, thanks!

    MariaDB and MySQL 8 both have REGEXP_REPLACE. A regex like this would probably work to find your bbcode: \[QT\].*\[\/QT\] Replace that with and empty string, and you'll remove the bbcode blocks from the messages.
  8. Hey Jim R, I just want to say that I'm pleased to see you letting go of some of your preconceived notions. There are few people with both the expertise and patience Barand brings to these forums. In my career I've designed and engineered systems for companies like Paramount Pictures, Industrial Light & Magic, Blizzard Entertainment, Sierra Online and many more I won't elaborate. Some of the systems have had millions of users and 100's of millions of rows in individual tables. Please take it from me that you're getting amazing advice from a professional who is an authority on anything having to do with relational database design, SQL or web systems based on a relational database.
  9. Any decent editor with PHP support should have shown you the issue with a missing bracket or parens. What are you using to edit your code? It also would have been easy to see if you indented your code. I'm not sure if that was an issue with cutting and pasting or if you are writing your code that way, but if you are, that is a terrible habit and one you should remedy immediately. Again most editors support basic indent/outdent pretty well in most cases. One thing that would help is to have your } else { and } else if () { On one line. Here's what I'd expect your code to look like in an editor: <?php if (isset($_POST['login-submit'])) { require 'dbh.inc.php'; $mailuid = $_POST['mailuid']; $password = $_POST['pwd']; if (empty($mailuid) || empty($password)) { header("Location: ../index.php?error=emptyfields"); exit(); } else { $sql = "SELECT * FROM users WHERE uidUsers=? OR emailUsers=?;"; $stmt = mysqli_stmt_init($conn); if (!mysqli_stmt_prepare($stmt, $sql)) { header("Location: ../index.php?error=sqlerror"); exit(); } else { mysqli_stmt_bind_param($stmt, "ss", $mailuid, $mailuid); mysqli_stmt_execute($stmt); $result = mysqli_stmt_get_result($stmt); if ($row = mysqli_fetch_assoc($result)) { $pwdCheck = password_verify($password, $row['pwdUsers']); if ($pwdCheck == false) { header("Location: ../index.php?error=wrongpwd"); exit(); } else if ($pwdCheck == true) { session_start(); $_SESSION['userId'] = $row['idUsers']; $_SESSION['userUid'] = $row['uidUsers']; header("Location: ../index.php?login=success"); exit(); } else { header("Location: ../index.php?error=wrongpwd"); exit(); } } else ( header("Location: ../index.php?error=nouser"); exit(); } } else { header("Location: ../index.php"); exit(); } } With proper indentation, the structure of the logic is visible and can be followed.
  10. gizmola

    Xdebug installation

    How is PHP integrated into the browser? Is it Apache with mod_php, nginx with php-fpm? Also did you run command line php (php -i) and see if the module is showing there? What xdebug configuration do you have? Is there an xdebug.ini, and if so where, and what are the contents?
  11. gizmola

    Problem with Form URL in PHP Code

    You didn't provide the actual code that does the redirect upon form submission, so it's anyone's guess.
  12. gizmola

    Help with embedding Google SMTP mail function.

    Your original source literally has this code: $email_message = '<html><body>'; $email_message .= '<table rules="all" style="border-color: #666;" cellpadding="10">'; $email_message .= "<tr style='background: #eee;'><td><strong>Request</strong></td></tr>"; $email_message .= "<tr style='background: #fff;'><td></td><td>" . "</td></tr>"; $email_message .= "<tr style='background: #eee;'><td><strong>Requested By:</strong> </td><td>" . strip_tags($_POST['query']) . "</td></tr>"; $email_message .= "<tr style='background: #eee;'><td><strong>Assigned To:</strong> </td><td>" . strip_tags($_POST['assigned']) . "</td></tr>"; $email_message .= "<tr style='background: #eee;'><td><strong>Contact Email:</strong> </td><td>" . strip_tags($_POST['senderemail']) . "</td></tr>"; $email_message .= "<tr style='background: #eee;'><td><strong>New Part Number:</strong> </td><td>" . strip_tags($_POST['partno']) . "</td></tr>"; $email_message .= "<tr style='background: #eee;'><td><strong>Item Description:</strong> </td><td>" . strip_tags($_POST['item']) . "</td></tr>"; $email_message .= "<tr style='background: #eee;'><td><strong>Expected Annual Volume:</strong> </td><td>" . strip_tags($_POST['volume']) . "</td></tr>"; $email_message .= "<tr style='background: #eee;'><td><strong>Supplier 1:</strong> </td><td>" . strip_tags($_POST['sup1']) . "</td></tr>"; $email_message .= "<tr style='background: #eee;'><td><strong>Quotation Received:</strong> </td><td>" . strip_tags($_POST['rec1']) . "</td></tr>"; $email_message .= "<tr style='background: #eee;'><td><strong>Supplier 2:</strong> </td><td>" . strip_tags($_POST['sup2']) . "</td></tr>"; $email_message .= "<tr style='background: #eee;'><td><strong>Quotation Received:</strong> </td><td>" . strip_tags($_POST['rec2']) . "</td></tr>"; $email_message .= "<tr style='background: #eee;'><td><strong>Supplier 3:</strong> </td><td>" . strip_tags($_POST['sup3']) . "</td></tr>"; $email_message .= "<tr style='background: #eee;'><td><strong>Quotation Received:</strong> </td><td>" . strip_tags($_POST['rec3']) . "</td></tr>"; $email_message .= "<tr style='background: #eee;'><td><strong>Supplier 4:</strong> </td><td>" . strip_tags($_POST['sup4']) . "</td></tr>"; $email_message .= "<tr style='background: #eee;'><td><strong>Quotation Received:</strong> </td><td>" . strip_tags($_POST['rec4']) . "</td></tr>"; $email_message .= "<tr style='background: #eee;'><td><strong>Email Subject:</strong> </td><td>" . strip_tags($_POST['subject']) . "</td></tr>"; $email_message .= "<tr style='background: #eee;'><td><strong>Message:</strong> </td><td>" . strip_tags($_POST['message']) . "</td></tr>"; $email_message .= "</body></html>"; So, with phpMailer ---- $email_message = '<html><body>'; $email_message .= '<table rules="all" style="border-color: #666;" cellpadding="10">'; $email_message .= "<tr style='background: #eee;'><td><strong>Request</strong></td></tr>"; $email_message .= "<tr style='background: #fff;'><td></td><td>" . "</td></tr>"; $email_message .= "<tr style='background: #eee;'><td><strong>Requested By:</strong> </td><td>" . strip_tags($_POST['query']) . "</td></tr>"; $email_message .= "<tr style='background: #eee;'><td><strong>Assigned To:</strong> </td><td>" . strip_tags($_POST['assigned']) . "</td></tr>"; $email_message .= "<tr style='background: #eee;'><td><strong>Contact Email:</strong> </td><td>" . strip_tags($_POST['senderemail']) . "</td></tr>"; $email_message .= "<tr style='background: #eee;'><td><strong>New Part Number:</strong> </td><td>" . strip_tags($_POST['partno']) . "</td></tr>"; $email_message .= "<tr style='background: #eee;'><td><strong>Item Description:</strong> </td><td>" . strip_tags($_POST['item']) . "</td></tr>"; $email_message .= "<tr style='background: #eee;'><td><strong>Expected Annual Volume:</strong> </td><td>" . strip_tags($_POST['volume']) . "</td></tr>"; $email_message .= "<tr style='background: #eee;'><td><strong>Supplier 1:</strong> </td><td>" . strip_tags($_POST['sup1']) . "</td></tr>"; $email_message .= "<tr style='background: #eee;'><td><strong>Quotation Received:</strong> </td><td>" . strip_tags($_POST['rec1']) . "</td></tr>"; $email_message .= "<tr style='background: #eee;'><td><strong>Supplier 2:</strong> </td><td>" . strip_tags($_POST['sup2']) . "</td></tr>"; $email_message .= "<tr style='background: #eee;'><td><strong>Quotation Received:</strong> </td><td>" . strip_tags($_POST['rec2']) . "</td></tr>"; $email_message .= "<tr style='background: #eee;'><td><strong>Supplier 3:</strong> </td><td>" . strip_tags($_POST['sup3']) . "</td></tr>"; $email_message .= "<tr style='background: #eee;'><td><strong>Quotation Received:</strong> </td><td>" . strip_tags($_POST['rec3']) . "</td></tr>"; $email_message .= "<tr style='background: #eee;'><td><strong>Supplier 4:</strong> </td><td>" . strip_tags($_POST['sup4']) . "</td></tr>"; $email_message .= "<tr style='background: #eee;'><td><strong>Quotation Received:</strong> </td><td>" . strip_tags($_POST['rec4']) . "</td></tr>"; $email_message .= "<tr style='background: #eee;'><td><strong>Email Subject:</strong> </td><td>" . strip_tags($_POST['subject']) . "</td></tr>"; $email_message .= "<tr style='background: #eee;'><td><strong>Message:</strong> </td><td>" . strip_tags($_POST['message']) . "</td></tr>"; $email_message .= "</body></html>"; $mail->Body = $email_message; The $mail->AltBody should be a version of the same data without the html, and just newline characters after each line.
  13. gizmola

    Error establishing a database connection

    I tend to start by verification of the username and password using the mysql command line client. Do the credentials work? If the db is on a separate non localhost server (-h someserver.someplace ) then this will help you debug that issue. Many things in PHP having to do with mysql connectivity have changed in recent years, not the least of which is the removal of the mysql_ library which old versions of wordpress used. Assuming PHP has been upgraded on the server, but wordpress has not, it is quite likely that upgrading wordpress to a current version will fix the issue. Of course, make sure you have full and complete OS and database backups before you start down that road.
  14. gizmola

    Help with embedding Google SMTP mail function.

    PHP's built in mail() function is designed to dump off mail to a system Mail Transfer Agent (MTA). It is not a full blown implementation of SMTP with support for SSL etc. To get that level of functionality, unless you plan to spend a good amount of time writing this to SMTP and Email format RFC standards, it is advisable to use a library. The traditional answer to this question involves pointing you to the PHPMailer library. PHPMailer source is here: https://github.com/PHPMailer/PHPMailer I am a big fan of things that have come from the Symfony project, and they have an alternative to PHPMailer named Swiftmailer. Swiftmailer is here: https://swiftmailer.symfony.com/docs/index.html Either library will do the job for you, so I'd advise you look at both and use whichever one you like the best, or that fits in with your overall project.
  15. gizmola

    Help with undefined variable error.

    You've made this really annoying by posting a screenshot rather than the code into a code block. In your screenshot go to the code on line #25 in your editor. Add a new blank line. For that blank line add this code: die('<pre>' . $content_to_eval . '</pre>'); Run the script, and it should output a string in a box. That is what was requested -- essentially the code the plugin is attempting to eval().
×

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.