Jump to content


  • Posts

  • Joined

  • Last visited

Recent Profile Visitors

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

Beauford2016's Achievements


Member (2/5)



  1. Thanks for the reply kicken I'll play around with that and see how it works out.
  2. I thought the question was well laid out myself. The reason I asked it this way is it is every piece of code I write where a variable is concerned I have to fight with this error. I can post every script I have written if you want to sift through them all, but I am asking in general how do I write ANY code so as not to get these errors. I thought defining $variable = "" like this at the beginning of my page would solve this, but in many cases not. If somewhere down the code I use $variable = "Whatever", boom, undefined variable $variable - or in other cases undefined index depending on the variable. If this isn't enough for anyone to help, not a problem, I'll move on. Cheers, benanamen: chill man, you gonna bust an artery.
  3. I don't know who did this or why this was implemented, but it was the worst decision PHP made as it causes nothing but problems. Not having to define variables was one of the reasons I liked PHP. This is just my opinion so no roasts. Question is, what is the proper way to do this so I don't get this message 'cause I am hit and miss, even when I think I have them defined this stupid message pops up. This is the 3rd line on the on script that is causing me grief at the moment: $submit = $populate = $record = $row[] = $hid = $uid = $asset_tag = $type = $manufacturer = $model = $serial_number = $status = $location = $firstname = $lastname = $go = ""; Not sure why I need to have $row[] as it is the result of a SELECT and values are being given to it. Also not sure why I need it for $submit or $_POST as they already have values when they are passed to this page, so how can they be undefined when they have values. Just not getting it. Any help with this would really be appreciated. Thanks
  4. Thanks Barands, that works perfectly. I knew I was in the right area but just couldn't get it exactly. Thanks also mac_guyver for your response.
  5. I have two tables, an assets and a users table. In both tables there is a UID row. If an asset is assigned to a particular user the UID's in both tables will be the same, if not the UID in the assets table will be 0. So what I am trying to do is select the two tables based on the particular asset and whether or not a user is assigned to it. If there is no user I just display the assets information if there is a user I want to display that as well. I have tried various different combinations of joins without any luck, below is just one of the failures. $q = "SELECT * FROM assets t1 join users t2 WHERE t1.hid =".$record." and t1.uid = t2.uid"; hid is the primary key for assets table and is an auto_increment # and I want to see if there are any users associated with this asset based on the uid in both tables. If the uid is 0 in the assets table then no users are associated, If the number is say 2, then it will be associated to the user with that #, and uid is the primary key in the users table. Hope this makes sense and someone can help me with an answer. Thanks
  6. Got it, finally............. $vu = "<a href=viewuser.php?u=".$r['userid']." "; $cs = $csscode[$r['userlevel']-1].">".$r['username']."</a> "; $ui = "[".$r['userid']."] was added to your hitlist"; gangevent_add_2($gangdata['gangID'], $vu." ".$cs." ".$ui); Left the single quotes around '$text'. The above might of worked on one line, but never tried it. Thanks
  7. I changed this so that id='member' generates id="member" and tried with leaving the single quotes around $text and also with removing them. Same issue. $csscode = array('id="member"','id="admin"','id="gm"','id="fm"','id="et"','id="mm"','id="ow"','id="ow"'); Also tried this - no quotes on member: $csscode = array('id=member','id="admin"','id="gm"','id="fm"','id="et"','id="mm"','id="ow"','id="ow"'); } Thanks
  8. I have an old site written for PHP 5.4 and under and trying (very trying) to get it to work with PHP 7x without much luck. Due to all the changes in 7 my code is one big error message, but one thing at a time. I cannot get the follow code to work at all, even though it worked in PHP 5. Error: QUERY ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'viewuser.php?u=666' id='member'>THE PREDATOR [666] was added to the hit' at line 1 The Query was INSERT INTO gangevents VALUES('','20', UNIX_TIMESTAMP(),'THE PREDATOR [666] was added to the hit list.') I have tried at least 20+ different ways of doing this but just can't get the right syntax to get it inserted into MySQL, the code below is just the latest version. If I echo the a href line out, it works perfect. I am sure it is something ridiculously simple, but I have been 4 hours and counting on this now. Thanks gangevent_add_2($gangdata['gangID'], "<a href='viewuser.php?u=".$r['userid']."' ".$csscode[$r['userlevel']-1].">".$r['username']."</a> [".$r['userid']."] was added to your hitlist"); function gangevent_add_2($gang, $text) { global $db; $csscode; $db->query("UPDATE users SET gangevent = gangevent + 1 WHERE gang={$gang}"); $db->query("INSERT INTO gangevents VALUES('','$gang', UNIX_TIMESTAMP(),'$text')"); }
  9. Can someone please, please, please tell me wtf is going here before I go totally postal and shoot up my ISP. If I insert this code at the top of any of my web pages it halts the page and nothing below it gets processed. I just get a blank page. Even if I try to make an error on purpose, nothing, just a blank page. All this works perfectly on PHP 5.4 and under. Currently using 5.6 which I downgraded from 7.2 thinking maybe that was an issue. Running on Linux Mint 19. I thought this might be a good hobby since I had a spare laptop just lying around, but maybe I was mistaken - too much time already wasted today on this. Not like the old Slackware days. I have tried the "serverhost" etc without quotes as well. I can't post all what I have done today, but I must have been on a 100 websites and tried 100 different iterations of the below code. Thanks <?php define("serverhost", "localhost"); define("serveruser", "test"); define("serverpass", "pass"); $db = "mydb"; $connect = mysqli_connect("serverhost", "serveruser", "serverpass", $db); if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); exit(); } ?>
  • 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.