PHP - Catchable Fatal Error
I'm creating a Contact Us page that has a form users may use to send a message.
I've run into an issue and I have never seen this error before. Could anyone help explain how to fix this please? Catchable fatal error: Object of class stdClass could not be converted to string in /homepages/30/d354929366/htdocs/contact.php on line 13 Line 13 is: $contactsql = "SELECT * FROM users WHERE username='$username'"; <?php include("inc/config.php"); include_once("inc/functions.php"); $ip = $_SERVER['REMOTE_ADDR']; $username = $_SESSION['customer']; $submit = (isset($_POST['submit'])); $to = "myemail@gmail.com"; $subject = "New Contact!"; $contactsql = "SELECT * FROM users WHERE username='$username'"; $result = mysql_query($contactsql); $row = mysql_fetch_assoc($result); $userid = $row['userid']; $name = $row['name']; $email = $row['email']; $username = $row['username']; if($submit){ if(!isset($_SESSION['customer'])){ $getusername = mysql_query("SELECT username FROM users WHERE email='$email'"); $getrow = mysql_fetch_assoc($getusername); $username = $getrow['username']; } $answered = 0; $date = date("Y-m-d"); $name = mysql_safe($_POST["name"]); $email = mysql_safe($_POST["email"]); $message = mysql_safe($_POST["comments"]); $name = $name; $email = $email; if($name){ if($email){ if($comments){ $success = "<div id='contsuccess'>We have received your message!</div>"; $newcontquery = "INSERT INTO contact VALUES ('','$userid','$username','$name','$email','$message','$answered','$date')"; mysql_query($newcontquery); mail("$to", "$subject", "My Site Title","From: admin@mysite.com"); } else{ $error = "<div id='conterror'>Please type a question or comment!</div>"; } } else{ $error = "<div id='conterror'>Type in your Email!</div>"; } } else{ $error = "<div id='conterror'>Type in your Name!</div>"; } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Language" content="en" /> <meta http-equiv="Content-Type" content="text/html; charset=windows-1251" /> <title> my site </title> <meta name="description" content="" /> <meta name="keywords" content="" /> <link rel="stylesheet" type="text/css" href="styles/main.css" /> <!--[if lt IE 7]> <link rel="stylesheet" type="text/css" href="styles/ie6.css" media="screen" /> <![endif]--> <!--[if gte IE 7]> <link rel="stylesheet" type="text/css" href="styles/ie7.css" media="screen" /> <![endif]--> </head> <body id="contact"> <div id="wrap"> <? include("inc/header/header.php")?> <div id="cwrap"> <div id="content"> <center><p><?php echo $success, $error; ?></p></center> <div class="contGen"> <FORM ACTION="contact.php" METHOD="POST" name="contactform1"> <div id="contformfirst">First Name: </div> <div id="contformfirstfld"><INPUT NAME="name" SIZE="30" class="FormField" value="<?php echo $dbfname; ?>"></div> <div id="contformemail">E-mail: </div> <div id="contformemailfld"><INPUT NAME="email" SIZE="30" class="FormField" value="<?php echo $dbemail; ?>"></div> <div id="contformcomments"><br><br>Comments: </div> <div id="contformcommentsfld"><textarea NAME="comments" rows="6" cols="23" SIZE="250"></textarea></div> <div id="contformsubmit"></div> <div id="contformreset"><input type='submit' name='submit' value='Submit'> <input type='reset' value='Reset'></div> </FORM> </div> </div> <? include("inc/left/leftnav.php")?> </div> <? include("inc/content/footer.php")?> </div> </body> </html> </body> </html> Similar TutorialsCatchable fatal error: Object of class Person could not be converted to string in D:\Program Files\AppServ\www\Project 1\FrontSide\Spawner.php on line 8 Spawner.php <html><body> <?php require_once("../Person/Person.php"); $count = $_POST['count']; $add = 0; while ($add < $count) { $one.$add = new Person('laryy'); $add++; } $one->getInfo('age'); ?> </body></html> I don't understand what's wrong. If you need more of the code please ask im getting this error "Catchable fatal error: Object of class variant could not be converted to string in C:\wamp\www\mdb\1mdb.php on line 36" <td><?php echo $make; ?></td> no matter what i use as the query it always shows this error on the last row even a query that has 3 results it only shows the 1st 1(every other row echo's fine). its not a problem with the data as i switch between asc and dsc in the query every row shows at some point. im thinking that maybe the looping needs to be told to stop, but i can n ot find any info that makes sense to me on google. thanks <?php $conn = new COM("ADODB.Connection") or die("Cannot start ADO"); // Microsoft Access connection string. $conn->Open("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=C:\\wamp\\www\\mdb\\one.mdb"); // SQL statement to build recordset. $rs = $conn->Execute("SELECT * from OneTouchImaging where make like 'toshiba' order by sku"); ?> <table border="1"> <?php // Display all the values in the records set while (!$rs->EOF) { $make = $rs->Fields["Make"]; $model = $rs->Fields["Model"]; $cpu = $rs->Fields["Cpu"]; $disksize = $rs->Fields["DiskSize"]; $bios = $rs->Fields["BIOS"]; $sku = $rs->Fields["SKU"]; $user = $rs->Fields["User"]; $model->value."<br>\n"; $make->value."<br>\n"; $cpu->value."<br>\n"; $disksize->value."<br>\n"; $bios->value."<br>\n"; $sku->value."<br>\n"; $user->value."<br>\n"; $rs->MoveNext(); ?> <tr> <td><?php echo $make; ?></td> <td><?php echo $model; ?></td> <td><?php echo $cpu; ?></td> <td><?php echo $disksize; ?></td> <td><?php echo $bios; ?></td> <td><?php echo $sku; ?></td> <td><?php echo $user; ?></td> <?php } $rs->Close(); ?> </tr> </table> Hi all, sorry about the subject as I wernt sure what to call it but anyway, Ive re coded a feature on my website which gives the user a chance to race agienst the computer but ive got an error saying: Catchable fatal error: Object of class stdClass could not be converted to string in /home/www/*****/test/test.php on line 52 <?php session_start(); include ("../includes/config.php"); include ("../includes/functions.php"); logincheck(); ini_set ('display_errors', 1); error_reporting (E_ALL); $username = $_SESSION['username']; $userstuff = mysql_query ("SELECT * FROM users WHERE username = '$username'") or die (mysql_error()); $user = mysql_fetch_object($userstuff); $garstu = mysql_query ("SELECT * FROM garage WHERE owner='$username'") or die (mysql_error()); $garage = mysql_fetch_object($garstu); $usercar = mysql_query ("SELECT carid FROM users WHERE username='$username'") or die (mysql_error()); $carin = mysql_fetch_object($usercar); $time= time() + 120; // Waiting time. if ($user->lastraceone > time()){ $left = $user->lastraceone - time(); echo "<center><b><font color=white>You Must Wait $left seconds before you race agian!</font></b></center>"; exit(); } // Use function to make sure there in a car.. function carcheck(){ if (empty($carin)){ echo ("You must be in a car before doing any races."); } else{ echo ("You are currently in: $carin."); } } // End function if (isset($_POST['race'])){ $race = $_POST['radiobutton']; carcheck(); //////////////////////////////////////// RACE 1 ///////////////////////////////////////////// if ($race == "1"){ // Rep gained $rand = rand(1000,10000); // Money gained $randmoney = rand(1000,15000); // Fuel used $randfuel = rand(3,10); mysql_query ("UPDATE users SET lastraceone = '$time' AND rep = 'rep+$rand' AND money = 'money+$randmoney' WHERE username='$username'") or die (mysql_error()); mysql_query ("UPDATE garage SET fuel = 'fuel-$randfuel' WHERE id = '$carin'") or die (mysql_error()); // Line 52 echo ("Well Done! You won: £$randmoney and $rand Rep. You also used $randfuel liters of fuel."); } /////////////////////////////////////// RACE 2 //////////////////////////////////////////// if ($race == "2"){ // Rep gained $random = rand(1000,10000); // Money gained $ranmoney = rand(1000,15000); // Fuel used $randomfuel = rand(3,10); mysql_query ("UPDATE users SET lastraceone = '$time' AND rep = 'rep+$random' AND money = 'money+$ranmoney' WHERE username='$username'") or die (mysql_error()); mysql_query ("UPDATE garage SET fuel = 'fuel-$randomfuel' WHERE id = '$carin'") or die (mysql_error()); echo ("Well Done! You won: £$ranmoney and $random Rep. You also used $randomfuel liters of fuel."); } } ?> <form action='' method='post' name='thisform'> Race along the Streets: <input name='radiobutton' type='radio' value='1'><br /> Race along A Drag Strip: <input name='radiobutton' type='radio' value='2'><br /> <input type='submit' name='race' Value='Race!'> mysql_query ("UPDATE garage SET fuel = 'fuel-$randfuel' WHERE id = '$carin'") or die (mysql_error()); // Line 52 Also line 52 is stated in the script I havent fully tested my script yet, while it not completly finished. But can anyone see why its giving me that error and how / or I can sort it please? Thanks for your help. I have the following script: <?php $tijd[] = '2012-05-23T02:00:00'; $date = new DateTime($tijd[0]); echo $date; ?> However it is not working and resulting in: Quote Catchable fatal error: Object of class DateTime could not be converted to string in time3.php on line 7 I think to solve this issue, I have to convert $tijd[0] into a string. Right? If this is correct, how do I do that? Hi everyone, I get this error: Catchable fatal error: Object of class Category could not be converted to string The code: public static function list_all_cat_names() { $result_array = self::find_by_sql("SELECT name FROM ".self::$table_name); return !empty($result_array) ? array_shift($result_array) : false; } $categories = Category::find_all(); foreach ($categories as $cats): echo $cats; endforeach; Where could be the problem? Hello all,
Appreciate if you folks could pls. help me understand (and more importantly resolve) this very weird error:
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation: 1064 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 'ASC, purchase_later_flag ASC, shopper1_buy_flag AS' at line 3' in /var/www/index.php:67 Stack trace: #0 /var/www/index.php(67): PDO->query('SELECT shoplist...') #1 {main} thrown in /var/www/index.php on line 67
Everything seems to work fine when/if I use the following SQL query (which can also be seen commented out in my code towards the end of this post) :
$sql = "SELECT shoplist.*, store_master.store_name, item_master.item_name FROM shoplist, store_master, item_master WHERE shoplist.store_id = store_master.store_id AND shoplist.item_id = item_master.item_id";However, the moment I change my query to the following, which essentially just includes/adds the ORDER BY clause, I receive the error quoted above: $sql = "SELECT shoplist.*, store_master.store_name, item_master.item_name FROM shoplist, store_master, item_master ORDER BY purchased_flag ASC, purchase_later_flag ASC, shopper1_buy_flag ASC, shopper2_buy_flag ASC, store_name ASC) WHERE shoplist.store_id = store_master.store_id AND shoplist.item_id = item_master.item_id";In googling for this error I came across posts that suggested using "ORDER BY FIND_IN_SET()" and "ORDER BY FIELD()"...both of which I tried with no success. Here's the portion of my code which seems to have a problem, and line # 67 is the 3rd from bottom (third last) statement in the code below: <?php /* $sql = "SELECT shoplist.*, store_master.store_name, item_master.item_name FROM shoplist, store_master, item_master WHERE shoplist.store_id = store_master.store_id AND shoplist.item_id = item_master.item_id"; */ $sql = "SELECT shoplist.*, store_master.store_name, item_master.item_name FROM shoplist, store_master, item_master ORDER BY FIND_IN_SET(purchased_flag ASC, purchase_later_flag ASC, shopper1_buy_flag ASC, shopper2_buy_flag ASC, store_name ASC) WHERE shoplist.store_id = store_master.store_id AND shoplist.item_id = item_master.item_id"; $result = $pdo->query($sql); // foreach ($pdo->query($sql) as $row) { foreach ($result as $row) { echo '<tr>'; print '<td><span class="filler-checkbox"><input type="checkbox" name="IDnumber[]" value="' . $row["idnumber"] . '" /></span></td>';Thanks Hello , I have a made a PHP website where users signup and send their Date of Birth and gets an OTP on their email after signup. The OTP is recieved but when we enter the OTP this problem occurs QuoteError! Something went wrong and I am facing this error in the error log QuotePHP Fatal error: Uncaught Error: Object of class DateTime could not be converted to string This is my config.php code <?php session_start(); ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Confirmation Page - Kanha Stories</title> <style> body { background-color: #330000; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100%25' height='100%25' viewBox='0 0 800 400'%3E%3Cdefs%3E%3CradialGradient id='a' cx='396' cy='281' r='514' gradientUnits='userSpaceOnUse'%3E%3Cstop offset='0' stop-color='%23D18'/%3E%3Cstop offset='1' stop-color='%23330000'/%3E%3C/radialGradient%3E%3ClinearGradient id='b' gradientUnits='userSpaceOnUse' x1='400' y1='148' x2='400' y2='333'%3E%3Cstop offset='0' stop-color='%23FA3' stop-opacity='0'/%3E%3Cstop offset='1' stop-color='%23FA3' stop-opacity='0.5'/%3E%3C/linearGradient%3E%3C/defs%3E%3Crect fill='url(%23a)' width='800' height='400'/%3E%3Cg fill-opacity='0.4'%3E%3Ccircle fill='url(%23b)' cx='267.5' cy='61' r='300'/%3E%3Ccircle fill='url(%23b)' cx='532.5' cy='61' r='300'/%3E%3Ccircle fill='url(%23b)' cx='400' cy='30' r='300'/%3E%3C/g%3E%3C/svg%3E"); background-attachment: fixed; background-size: cover; padding: 20px; width: 100vw; height: 100vh; display: flex; align-items: center; justify-content: center; color:#ffffff; overflow-x: hidden; } .cont { padding: 20px 40px; position: relative; border-right: 4px solid rgb(184, 182, 182); border-bottom: 4px solid rgb(184, 182, 182); border-radius: 15px; display: flex; flex-direction: column; align-items: center; } #left{ float: left; } #right{ float: right; } input{ margin: 10px 0px; } s{ padding: 5px; } .error{ padding: 5px; color: #ffffff; } .resend{ color: rgb(14, 14, 196); padding: 5px; } .s:hover{ cursor: pointer; background-color:gray; color: rgb(243, 237, 237); border-radius: 5px; } </style> </head> <body> <?php $code=""; $err=""; $error=""; if(($_SERVER["REQUEST_METHOD"]=="GET" && $_SESSION['xyz'] === 'xyz') || isset($_POST['verify']) || isset($_POST['resend'])) { unset($_SESSION["xyz"]); if($_SERVER["REQUEST_METHOD"] ==="POST") { if(isset($_POST['verify'])) { if(empty($_POST['code'])) { $err="Enter the code!"; } else { $code=$_POST['code']; if(password_verify($code,$_SESSION['code'])) { $name=$_SESSION['name']; $email=$_SESSION['email']; $tel=$_SESSION['tel']; $dob=$_SESSION['dob']; $password=$_SESSION['password']; $age_category=$_SESSION['age_category']; require_once('./all_utils/connection.php'); $sql="INSERT INTO identity_table(name,email,password,tel,dob,age_category) VALUES ('$name','$email','".$password."','$tel','$dob','$age_category')"; if(mysqli_query($conn,$sql) === TRUE) { unset($_SESSION["name"]); unset($_SESSION["password"]); unset($_SESSION["dob"]); unset($_SESSION["tel"]); unset($_SESSION["age_category"]); header("location:welcome/welcome.php"); } else { $err="Error! Something went wrong"; } } else { $err="Incorrect code!"; } } } elseif(isset($_POST['resend'])) { require_once('./all_utils/mail.php'); $error="OTP has been sent again!"; } } } else{ header("location:signup.php"); } ?> <div class="cont"> <h2> Email Verification</h2> <form action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']) ?>" method="POST"> <label for="verification">Enter the 5 digit code</label> <br/> <p> Didn't got the mail? Please check your spam folder </p> <input type="text" name="code" placeholder="Eg. 12345" value="<?php echo $code; ?>"> <br/> <div class="error"><?php echo $err; ?></div> <div class="resend"><?php echo $error;?></div> <input type="submit" name="resend" class="s" id="left" value="Resend OTP"> <input type="submit" name="verify" class="s" id="right" value="Verify"> </form> </div> </body> </html>
This is my signup.php code <?php session_start(); if(!empty($_SESSION['email'])) { require_once('./all_utils/connection.php'); $query="SELECT * FROM identity_table WHERE email='".$_SESSION['email']."'"; $result=mysqli_query($conn,$query); if(mysqli_fetch_assoc($result)) { header("location:welcome/welcome.php"); } } ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>SignUp - Kanha Stories</title> <style> * { margin: 0; padding: 0; } body { width: 100vw; height: 100vh; display: flex; align-items: center; background-color: #ff9d00; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100%25' height='100%25' viewBox='0 0 1600 800'%3E%3Cg stroke='%23000' stroke-width='66.7' stroke-opacity='0' %3E%3Ccircle fill='%23ff9d00' cx='0' cy='0' r='1800'/%3E%3Ccircle fill='%23f27d00' cx='0' cy='0' r='1700'/%3E%3Ccircle fill='%23e55f00' cx='0' cy='0' r='1600'/%3E%3Ccircle fill='%23d84400' cx='0' cy='0' r='1500'/%3E%3Ccircle fill='%23cb2c00' cx='0' cy='0' r='1400'/%3E%3Ccircle fill='%23bf1600' cx='0' cy='0' r='1300'/%3E%3Ccircle fill='%23b20300' cx='0' cy='0' r='1200'/%3E%3Ccircle fill='%23a5000e' cx='0' cy='0' r='1100'/%3E%3Ccircle fill='%2398001c' cx='0' cy='0' r='1000'/%3E%3Ccircle fill='%238b0027' cx='0' cy='0' r='900'/%3E%3Ccircle fill='%237e0030' cx='0' cy='0' r='800'/%3E%3Ccircle fill='%23710037' cx='0' cy='0' r='700'/%3E%3Ccircle fill='%2364003b' cx='0' cy='0' r='600'/%3E%3Ccircle fill='%2358003c' cx='0' cy='0' r='500'/%3E%3Ccircle fill='%234b003a' cx='0' cy='0' r='400'/%3E%3Ccircle fill='%233e0037' cx='0' cy='0' r='300'/%3E%3Ccircle fill='%23310030' cx='0' cy='0' r='200'/%3E%3Ccircle fill='%23210024' cx='0' cy='0' r='100'/%3E%3C/g%3E%3C/svg%3E"); background-attachment: fixed; background-size: cover; overflow-x: hidden; } .cont { color: #ffffff; width: 500px; margin: auto; } h2 { color: #ffffff; text-align: center; padding: 1.5px; } .error { text-align: center; padding: 20px; font-size: 1rem; color: rgb(233, 76, 76); } form { font-size: 1.2rem; /* width: 40%; */ /* margin: auto; */ } .in{ margin: 5px 0; } input { border: 2px solid white; padding: 10px; margin: 5px 0; font-size: 1rem; width: 100%; } input:hover { border: 2px solid rgb(228, 81, 81); cursor: text; } p,a{ text-align: center; font-size: 1rem; } a{ color: deepskyblue; font-size:20px; } #s{ text-decoration:none; border-radius: 12px; } #s:hover { cursor: pointer; } a { text-decoration: none; } @media only screen and (max-width: 600px){ .cont{ width: 300px; } .error,input{ font-size: 0.8rem; } } @media only screen and (max-width: 400px){ .cont{ width: 70%; } h2{ font-size: 1.3rem; } a,p{ font-size: 0.7rem; } label{ font-size: 1.0rem; } input{ padding: 4px; } } </style> </head> <body> <?php $name=""; $email=""; $tel=""; $dob=""; $err=""; $name_err=""; $email_err=""; $tel_err=""; $dob_err=""; $password_err=""; if($_SERVER["REQUEST_METHOD"]=="POST") { if(isset($_POST['signup'])) { if(empty($_POST['name']) || empty($_POST['dob']) || empty($_POST['tel']) || empty($_POST['email']) || empty($_POST['password'])) { if(empty($_POST['name'])) { $name_err="Name is required!"; } else{ $name=$_POST['name']; } if(empty($_POST['email'])) { $email_err="Email is required!"; } else{ $email=$_POST['email']; } if(empty($_POST['tel'])) { $tel_err="Contact Number is required!"; } else{ $tel=$_POST['tel']; } if(empty($_POST['dob'])) { $dob_err="D.O.B is required!"; } else{ $dob=$_POST['dob']; } if(empty($_POST['password'])) { $password_err="Password is required!"; } } else { $today = new DateTime(date('m.d.y')); $dob = new DateTime($_POST['dob']); $diff1 = $today->diff($dob); $age = $diff1->y; if($age > 15 || $age <3) { $dob = $_POST['dob']; $dob_err = "Age criteria not satisfied , child's age must be between 3-15 years"; } else { require_once("./all_utils/connection.php"); $email=$_POST['email']; $query="SELECT * FROM identity_table WHERE email='".$email."'"; $result=mysqli_query($conn,$query); if(mysqli_fetch_assoc($result)) { $err="Email alredy registered!"; $name=$_POST['name']; $email=$_POST['email']; } else { if($age < 7) { $_SESSION['age_category'] = '1'; } else { $_SESSION['age_category'] = '2'; } $_SESSION['name']=$_POST['name']; $_SESSION['email']=$_POST['email']; $_SESSION['password'] = password_hash($_POST['password'],PASSWORD_DEFAULT); $_SESSION['tel']=$_POST['tel']; $_SESSION['dob']=$_POST['dob']; $_SESSION['xyz']='xyz'; require_once("all_utils/mail.php"); header("location:conf.php"); } } } } } ?> <div class="cont"> <h2>SignUp - Kanha Stories</h2> <form action="<?php echo htmlspecialchars($_SERVER['PHP_SELF'])?>" method="POST"> <span class="error"><?php echo $err; ?></span> <br/> <label for="name">Name</label><br /> <input type="text" name="name" placeholder="Enter your name" value="<?php echo $name; ?>"> <span class="error"><?php echo $name_err; ?></span> <br/> <label for="email">Email</label><br /> <input type="email" name="email" placeholder="Enter your Email ID" value="<?php echo $email; ?>"> <span class="error"><?php echo $email_err;?></span> <br/> <label for="tel">Mobile Number</label><br /> <input type="tel" name="tel" placeholder="Enter Mobile Number" value="<?php echo $tel; ?>"> <span class="error"><?php echo $tel_err;?></span> <br/> <label for="date">D.O.B. of Child (Click on Calander icon)</label><br /> <input type="date" name="dob" placeholder="Enter date of birth " value="<?php echo $dob;?>"> <span class="error"><?php echo $dob_err;?></span> <br/> <label for="password">Password</label><br /> <input type="password" name="password" placeholder="Enter your Password"> <span class="error"><?php echo $password_err; ?></span> <br/> <div class="sub"> <input type="submit" name="signup" id="s" placeholder="Submit"><br /> </div> </form> <p>Already registered? <a href="./login.php">log in here</a></p> </div> </body> </html>
I don't know what I can do now , Please try to give me the solutions as soon as possible. Thanks I closed everything down last night and it was all fine, website was working as normal etc, but I've turned on the Xxamp server today and I am getting this error. Seems very random as nothing has changed since it was last on? Does anyone know how to sort this out and why I'm now getting this error? Thanks! Can anyone help me with this error? Fatal error: Call to a member function require_login() on a non-object in /home/wallls/public_html/index.php on line 27 Lines 26-33 below: <?php $smilek = $_GET['id']; $ppalout = $_GET['payout']; $healthy = array("%", "!", "=", "'", ",", "OR", "?", "<", "&", ";"); $yummy = array("", "", "", "", "" ,"", "", "", "", ""); $peee = str_replace($healthy, $yummy, $smilek); $chnpay = str_replace($healthy, $yummy, $ppalout); require_once 'appinclude.php'; require_once 'mystyle.php'; echo '<div align="center"><img src="'.$appcallbackurl.'main.png" width="300" height="150"></div>'; require_once 'ads/topads.php'; ?> <fb:tabs> <fb:tab-item href='<? echo $appCanvasUrl; ?>' title='Lottery' selected='true' /> <fb:tab-item href='<? echo $appCanvasUrl; ?>earn.php' title='Get Tickets' /> <fb:tab-item href='<? echo $appCanvasUrl; ?>payment.php' title='Payment Info' /> <fb:tab-item href='<? echo $appCanvasUrl; ?>history.php' title='Lottery History' /> <fb:tab-item href='<? echo $appCanvasUrl; ?>forum.php' title='Forum' /> <fb:tab-item href='<? echo $appCanvasUrl; ?>invite.php' title='Invite Friends' /> </fb:tabs> <div align="center"> <? $fbid = $facebook->require_login(); $theirip = $_SERVER['REMOTE_ADDR']; if ($fbid == "") { ?>
Hello everyone This topic has been moved to Other Libraries and Frameworks. http://www.phpfreaks.com/forums/index.php?topic=311225.0 Hi there, I have a local server set up on my computer which I have used before and it worked flawlessly. It is running apache with PHPand mySQL set up as services. Recently I attempted to copy a project I have worked on at school onto my server. I have the database up and running, however when I try to run a PHP file it gives me the error: Quote Fatal error: Cannot redeclare getText() in C:\Server\htdocs\projects\tournament\includes\functions.php on line 20 When I rename that function (which I know is not being redeclared) I get a browser error: Quote This webpage is not available. The webpage at http://localhost/projects/tournament/index.php might be temporarily down or it may have moved permanently to a new web address. More information on this error Below is the original error message Error 101 (net::ERR_CONNECTION_RESET): Unknown error. Has anybody else experienced this error and have a solution to fix it? My guess is that it has to do with the function gettext() being available on this machine but not on the machine at school, however I thought PHP was case sensitive? Hi, I am very new to PHP and I am trying to execute the below code but getting these errors : Notice: Undefined variable: mysql_query in C:\wamp\www\process.php on line 16 Fatal error: Function name must be a string in C:\wamp\www\process.php on line 16 Code: <html><body> <?php mysql_connect("localhost","root",""); mysql_select_db("encryption") or die(mysql_error()); $username = $_POST['username']; $password = $_POST['password']; $mysql_query("INSERT INTO login (username,password) VALUES ('$username','$password')") or die(mysql_error()); ?> </body></html> ` $_POST['username'] & $_POST['password'] come from a previous page. I have no problem with that. Please help.. Thanks in advance.
In PHP Version 8.0 shows error as : In previous versions of PHP it does not show any error. Please resolve the issue. Hi guys, I have managed to get all my oAuth to work (basically), however the autorize.php is getting this error when "Allowing". Any ideas why? Only happens once I press allow and it should have redirected to the REDIRECT_URI. Thanks in advance. HOW TO FIX Fatal error: Uncaught Error: Using $this when not in object context in /testynarkotykowe/libs/timer/index.php:13 Stack trace: #0 /testynarkotykowe/index.php(36): TIMER::getTime('all') #1 /testynarkotykowe/m/pg/index.php(110): PAGE->PAGE(NULL, 'cart') #2 /testynarkotykowe/index.php(28): include_once('/testynarkotyko...') #3 /testynarkotykowe/index.php(115): loadMod('pg') #4 {main} thrown in /testynarkotykowe/libs/timer/index.php on line 13 HOW TO TRACK THE ERROR? http://testynarkotykowe.j13x.pl/index.txt Quote<?php #error_reporting(0); define('PHP','.php'); require_once('_gz/php_speedy'.PHP); define('INX','index'); define('HTML','.html'); error_reporting(E_ALL ^ E_NOTICE); define('N','/'); ini_set('memory_limit','512M'); define('DIR_LIB','libs/'); define('DIR_MOD','m/'); define('DIR_TPL','tpl/'); define('DIR_LNG','lng/'); define('R_TIME',2*1000); define('PTH',''); define('HTTP','http://'); define('RANGE_IMG',5000); define('URL',HTTP.$_SERVER['HTTP_HOST'].N.PTH); define('_URL',HTTP.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']); define('TAX_RATE',0.08); /* for drug_tests [!] */ define('DOTPAY_ID',37953); define('POPUP_NW',"'mywindow','width=400,height=200,toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,copyhistory=yes,resizable=yes')"); define('_E','ENGINE | '); define('_LNG','X lng file in mod'); define('_DB','DB | '); define('H','Hacking Attempt | '); define('_C','COOKIE | '); define('_S','SESSION | '); define('NOREPLY','noreply'); define('WWW','www.'); define('JQ','jquery'); define('SEP',' | '); define('SP','|'); define('URI_SEP',','); define('BULK_URI','?bulk'); define('GUEST','Anonymous'); define('C_EXP',time()+24*3600*30); define('PP',14); define('TH_W',125); define('TH_H',75); define('TH',95); define('COUNTDOWN',7); define('HIDE','st'); define('NL',"\n"); define('DATETIME',date('Y-m-d H:i:s')); define('DATETIME_YESTERDAY',date("Y-m-d",time()-(60*60*24))); define('IMG_W',864); define('IMG_H',720); define('IMG_',70); define('IMG_TH','_th.'); define('IMG_AV','_avatar.'); define('MAIL_STYLE',' style="color:blue;text-decoration:underline"'); define('A4_W',946); define('A4_H',1334); /* 595,842 */ define('LIMIT_SIGNATURE',30); define('LIMIT_UTOPICS',16); define('HASH','#'); define('C_TIP_LIMIT',10); define('C_LIMIT',2);/*COMMENTS*/ define('WRAP0',42); define('WRAP1',370);/*74 x 5*/ define('LIMIT_PREFACE',300); define('hideAFTER',3000); define('ERASE_AFTER_X_DAYS',30); define('NOTIFS_LIMIT',2000); define('__ID','ID non'); define('__D','!digit'); define('__R','record non'); define('LOC','Location: '); define('PER_PG',10); define('PER_PG2',5); define('PER_PG3',25); define('PER_PG4',40); session_start(); define('DATETIME_NO','0000-00-00 00:00:00'); define('AminLENGTH',10); define('fade1',100); define('RANGE',50000); define('TH_PRE','th.'); define('TH_EXT','jpg'); define('USERNAME','0100000');/*OBLIGATORY: "0" on the beginning*/ define('USERNAME_LENGTH',strlen(USERNAME)); define('QMIN_LENGTH',10); define('BALANCE0',"0.00"); define('PIN_ATTEMPTS',5); define('MIN_AMOUNT',100); define('RATE0','0.0000'); function datetime($diff) { $timestamp=time(); $tm=86400*$diff; $tm=$timestamp+$tm; return $tm; } define('DATETIME1',date('Y-m-d H:i:s',datetime(1))); define('LANGUAGE','pl'); define('LNG',LANGUAGE.N); define('LG','_'.LANGUAGE); define('MIN_LENGTH',3); define('CURRENCY','PLN'); /* testy */ define('_DEFAULT_ITEM_CNT',4); define('_PROMO_ITEM_CNT',11); define('_PROMO_'.strtoupper(LANGUAGE).'_PRICE',115); define('_PROMO_'.strtoupper(LANGUAGE).'_BEFORE_PRICE',129); /*define('U_FIELDS','id,p,phone,mail,act_lnk,session,name');*/ define('URL_LENGTH',120); /* to 120 */ define('AUTOSAVE_DRAFT_TIME',60*1000); /* TESTY */ #if(!empty($_GET['uid'])) { if(ctype_digit($_GET['uid'])) { $_SESSION['ref'] = $_GET['uid']; unset($_SESSION['uid']); } header(LOC.URL); exit; }/* or $_SERVER['HTTP_HOST'] == 'www.testynarkotykowe.pl'*/ function loadLib($l) { $pth = DIR_LIB.strtolower($l).N.basename(INX).PHP; if(file_exists($pth)) include_once($pth); else die(_E.'loadLib [ '.$pth.' ]'); } function loadLang($l,$m) { $pth = DIR_LNG.strtolower($l).N.strtolower($m).N.basename(INX).PHP; if(file_exists($pth)) include_once($pth); else die(_E.'loadLang [ '.$pth.' ]'); } loadLib('url'); @URL::sUrl(); #try { $db = new PDO('mysql:host=localhost;dbname=andypsv_cocain','root','',array(PDO::ATTR_PERSISTENT=>true)); } catch(PDOException $e) { die('PDO::Can\'t connect'); } try { $db = new PDO('mysql:host=serwer2056122.home.pl;dbname=32538868_thejokerred','32538868_thejokerred','M98thiuhsnduit@@##^',array(PDO::ATTR_PERSISTENT=>true)); } catch(PDOException $e) { die('PDO::Can\'t connect'); } $db->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE,PDO::FETCH_ASSOC); define('PRFX','drugtests_'); $db->query('SET NAMES utf8'); $db->query('SET CHARACTER SET utf8'); $db->query('SET collation_connection = utf8_general_ci'); header('content-type:text/html;charset:utf-8'); $c = $db->query('SELECT * FROM '.PRFX.'cfg'.LG); if($c->rowCount() == 0) die(_E.'X cfg file'); $c = $c->fetch(); foreach($c as $k=>$v) define('PG_'.strtoupper($k),$v); define('PG_TPL',DIR_TPL.PG_TPLX.DIR_MOD); define('C_NAME',PG_T2); loadLib('ip'); loadLib('auth'); loadLib('pages'); loadLib('func'); loadLib('time'); function uQuery($GET) { if(substr($GET,0,USERNAME_LENGTH) == USERNAME) $sql = 'id = "'.substr($GET,USERNAME_LENGTH).'"'; else $sql = 'uri = "'.$GET.'"'; return $sql; } function rtrnLoc() { $LENGTH = strlen(URL); if($_SERVER['HTTP_REFERER'] == URL) return URL; else if(substr($_SERVER['HTTP_REFERER'],0,$LENGTH) == URL) return $_SERVER['HTTP_REFERER']; else return URL; } function arr_short($arr) { $res = array(); foreach($arr as $subArray) foreach($subArray as $k => $v) $res [$k] = $v; return $res; } function loadMod($m) { $pth = DIR_MOD.strtolower($m).N.INX.PHP; if(file_exists($pth)) include_once($pth); else exit(header(LOC.URL,true,301)); } function errLog($err) { global $db; $q = $db->query('INSERT INTO '.PRFX.'err (date,err) VALUES ("'.DATETIME.'","'.$err.'")'); if($q->rowCount() <> 1) die(H.'errLog, fatal failure [not logged error to db]'); else return substr(strstr($err,':'),2); } class PAGE { var $_t,$_k,$_d,$_c,$_nav,$_,$tpl,$u,$md; function PAGE($md='',$md2='',$md3='',$md4='') { global $db,$md; loadLib('timer'); @TIMER::setTimer('all'); require_once(DIR_LIB.DIR_TPL.'class.template'.PHP); $this->tpl = new Template_Lite; $_gTime = TIMER::getTime('all'); $this->tpl->assign('_gTime',$_gTime); $this->tpl->assign('URL',URL); define('TPL',URL.DIR_TPL.PG_TPLX); $this->tpl->assign('TPLx',DIR_TPL.PG_TPLX); $CONSTANS = get_defined_constants(); foreach($CONSTANS as $k => $v) $this->tpl->assign($k,$v); foreach($_POST as $k => $v) if(is_array($_POST[$k])) foreach($_POST[$k] as $k2 => $v2) $_POST[$k][$k2] = htmlspecialchars(trim($v2)); else $_POST[$k] = htmlspecialchars(trim($v)); foreach($_COOKIE as $k => $v) $_COOKIE[$k] = htmlspecialchars(trim($v)); $this->tpl->assign('_GET',$_GET); $this->tpl->assign('_POST',$_POST); $this->tpl->assign('_COOKIE',$_COOKIE); $this->tpl->assign('_SESSION',$_SESSION); $this->tpl->assign('INX',INX); $this->u = isUlogd(str_replace(' ','',PG_T2)); $this->tpl->assign('u',$this->u); $pth = DIR_LNG.LNG.INX.N.INX.PHP; if(file_exists($pth)) { include_once($pth); $lng_index = $_; } else die(_LNG.' [[ index ]]'); $md = strtolower($md.N); $pth = DIR_LNG.LNG.$md.INX.PHP; $this->md = $md; $this->tpl->assign('md',substr($md,0,-1)); if(file_exists($pth)) include_once($pth);/* else die(_LNG);*/ $LNG_all = array_merge($lng_index,$_); $_ = ''; /* HERE IS ISSUE WHEN A FILE IS __INCLUDED <br/> unnecessary, temp-fix: LNG_attached */ if(!empty($md2)) { $md2 = strtolower($md2.N); $pth = DIR_LNG.LNG.$md2.INX.PHP; if(file_exists($pth)) include_once($pth); else die(_LNG.'2: '.$pth); $md2_index = $_; $LNG_all = array_merge($LNG_all,$md2_index); } if(!empty($md3)) { $md3 = strtolower($md3.N); $pth = DIR_LNG.LNG.$md3.INX.PHP; if(file_exists($pth)) include_once($pth); else die(_LNG.'3: '.$pth); $md3_index = $_; $LNG_all = array_merge($LNG_all,$md3_index); } if(!empty($md4)) { $md4 = strtolower($md4.N); $pth = DIR_LNG.LNG.$md4.INX.PHP; if(file_exists($pth)) include_once($pth); else die(_LNG.'4: '.$pth); $md4_index = $_; $LNG_all = array_merge($LNG_all,$md4_index); } $this->_ = $LNG_all; $this->tpl->assign('_',$this->_); $this->tpl->assign('LG',substr(LG,1)); //? $this->tpl->assign('i_drugtests','drug_tests/'); if(ctype_digit(end(explode(',',$_GET[0])))) $this->tpl->assign('col2',1); $q = $db->query('SELECT * FROM '.PRFX.'c0'.LG); if($q->rowCount() == 0) die(_E.'no categories'); while($_c0 = $q->fetch()) $c0[] = $_c0; $this->tpl->assign('c0',$c0); #var_export($_SESSION); die; #session_destroy(); /* CART */ $q = $db->query('SELECT * FROM `'.PRFX.'products'.LG.'`'); if($q->rowCount() == 0) die(_DB.'no records'); while($cart = $q->fetch()) { $cart['t_url'] = _url($cart['t']); $cart['base'] = sprintf('%.2f',$cart['base']); $cart['unit_'] = preg_replace('#[0-9]+\.+[0-9]#i','',$cart['unit']); if(empty($cart['total'])) $cart['total'] = sprintf('%.2f','0'); $cart['t__'] = ucfirst($cart['t_']); $cart['illegal'] = str_replace("\n",'<br />',$cart['illegal']); if(isset($_SESSION['_'.$cart['t_']])) { $cart['amount'] = $_SESSION['_'.$cart['t_']]; // if($cart['unit'] == '0.1g') $cart['amount'] *= 10; $cart['total'] = sprintf('%.2f',$cart['base']*$cart['amount']); $cart['price_table'] = explode(NL,$cart['prices']); #$cart['discount'] = $cart['total']-(CART::getPrice($cart['price_table'],$cart['amount'])/($tax_rate+1)); if(substr($cart['discount'],0,1) == '-') $cart['discount'] = substr($cart['discount'],1); if($cart['unit'] == '0.1g') $cart['amount'] /= 10; } $_cart[] = $cart; } $this->tpl->assign('cart',$_cart); $this->tpl->assign('items_in_cart',array_sum_key($_cart,'amount')); $this->tpl->assign('cart_total',sprintf('%.2f',array_sum_key($_cart,'total'))); $q = $db->query('SELECT * FROM '.PRFX.'promotion WHERE ip = "'.getClientIp().'" LIMIT 1'); if($q->rowCount() == 0) { $db->exec('INSERT INTO '.PRFX.'promotion (ip,time,u) VALUES ("'.getClientIp().'","'.date('m/d/Y h:i A',strtotime(date('m/d/Y h:i A').' + 2 hours 56 minutes')).'","'.$this->u['nick'].'")'); $this->tpl->assign('countdownTime',date('m/d/Y h:i A',strtotime(date('m/d/Y h:i A').' + 2 hours 56 minutes'))); } else { $countdownTime = $q->fetch(); $this->tpl->assign('countdownTime',$countdownTime['time']); } } function run() { global $db; $_ON_LOGGED = $db->query('SELECT COUNT(*) FROM `'.PRFX.'u` WHERE session >= '.(time()-300)); $this->tpl->assign('_ON_LOGGED',$_ON_LOGGED->rowCount()); if(!empty($this->u['id'])) $db->exec('UPDATE `'.PRFX.'u` SET session = "'.time().'" WHERE id = "'.$this->u['id'].'" LIMIT 1'); else $this->u['nick'] = ''; $db->exec('DELETE FROM `'.PRFX.'u_on` WHERE DATE_ADD(time,INTERVAL 3 HOUR) < NOW()'); $q = $db->query('SELECT u FROM `'.PRFX.'u_on` WHERE ip = "'.getClientIp().'" LIMIT 1'); if($q->rowCount() == 1) $db->exec('UPDATE `'.PRFX.'u_on` SET time = NOW(),u = "'.$this->u['nick'].'" WHERE ip = "'.getClientIp().'" LIMIT 1'); else $db->exec('INSERT INTO `'.PRFX.'u_on` VALUES ("'.getClientIp().'",NOW(),"'.$this->u['nick'].'")'); $rlt = $db->query('SELECT COUNT(ip) FROM `'.PRFX.'u_on`'); $this->tpl->assign('_ON',$rlt->rowCount()); /* if(!empty($this->u['id'])) { $q = q('SELECT COUNT(*) AS total FROM (SELECT * FROM '.PRFX.'messages WHERE _to = "'.$this->u['id'].'" AND `read` = "0" GROUP BY _from ORDER BY id DESC) x ORDER BY id DESC LIMIT 1'); $cnt = f($q); $this->tpl->assign('new_messages',$cnt['total']); $q = q('SELECT COUNT(*) as total FROM '.PRFX.'notifications WHERE u_to = "'.$this->u['id'].'" AND `read` = "0" LIMIT 1'); $cnt = f($q); $this->tpl->assign('new_notifs',$cnt['total']); }*/ if(empty($this->_k)) $this->_k = PG_KEYWORDS; if(empty($this->_d)) $this->_d = PG_DESCRIPTION; if(empty($_GET[0])) $t = PG_T_MAIN; else if(empty($this->_t)) $t = ucfirst(PG_T_MAIN); else $t = $this->_t; #.SEP.PG_T; $this->tpl->assign('_t',$t); $this->tpl->assign('_k',$this->_k); $this->tpl->assign('_d',$this->_d); $this->tpl->assign('_nav',$this->_nav); $this->tpl->assign('_c',$this->_c); $this->tpl->display(DIR_TPL.N.PG_TPLX.INX.HTML); } #### function mbl($st=true,$redir=true,$loc='') { #if($this->u['ban'] == 1) die('Account Blocked (BAN)'); foreach($_GET as $k => $v) $uri .= $v.'/'; if($_SERVER['REQUEST_URI'] <> '/login') { if(empty($loc)) $loc = substr(str_replace('|login|','',$uri),0,-1); if(!empty($this->u['id']) AND $_GET[0] == 'login') exit(header(LOC.URL)); if(!$st) { if($this->u['id']) if($redir) exit(header(LOC.URL.$loc)); else return false; } else { if(!$this->u['id']) if($redir) exit(header(LOC.URL.'login'.N.$loc)); else return false; } } } } if(empty($_GET[0]) OR substr($_GET[0],0,1) == '?') loadMod(PG_H_MOD); elseif(is_dir(DIR_MOD.$_GET[0])) loadMod($_GET[0]); else { loadMod(PG_H_MOD); // die(H.'no mod'); } $compressor->finish(); ?>
Hi there, I get this message on my website when i click the clear cart button or the +- button Fatal error: Call to a member function GetCart() on a non-object in /hermes/web11b/b1267/moo.organicgrowshopcouk/cart.php on line 31 I'd really appreciate any help. thanks, Matt Hi, I'm getting below error in my page http://www.cidirealty.com/NWMLS/mls.php PHP Fatal error: Uncaught exception 'Exception' with message 'String could not be parsed as XML' in E:\USERS\cidirealty\www\NWMLS\mls.php:54 Stack trace: #0 E:\USERS\cidirealty\www\NWMLS\mls.php(54): SimpleXMLElement->__construct(' Does anyone know what this means and how to solve this? Thank you. this is my code Code: [Select] <?php require ("s_check_login.php"); include ('database.php'); if(isset($_POST['csv_btn'])){ $str = $_POST['csv']; $date = mysql_real_escape_string($_POST['date']); $gal = mysql_real_escape_string($_POST['gal']); $op = mysql_real_escape_string($_POST['op']); $parts = explode( "\n", $str ); $team = array(); foreach( $parts as $part ) $team[] = str_getcsv($part); unset($parts); $tcount = count($team); for($x=0; $x<$tcount; $x++){ $p = $team[$x]; $sql = "INSERT INTO gbsa_stats (id, Player, Day_Played, Opponent, Gallery_no, Goals, Assists, Shots, On_Goal, Off_Post, Offsides, Saves, Fouls, Shots_Corner, Goals_Corner, Yellow, Red) VALUES ('NULL','$p[1]','$date','$op','$gal','$p[2]','$p[3]','$p[4]','$p[5]','$p[6]','$p[7]','$p[8]','$p[9]','$p[10]','$p[11]','$p[12]','$p[13]')"or die ('Error Updateing Database ' .mysql_error()); if (!mysql_query($sql)){ die('Error : ' .mysql_error()); } } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title></title> </head> <body> <form id="form1" name="form1" method="post" action=""> <h1>csv data:</h1> <textarea name="csv" cols="100" rows="25" id="csv"></textarea> <br /> <h1>Date:</h1> <input type="text" name="date" id="date" /> <br /> <h1>Opponent:</h1> <input type="text" name="op" id="op" /> <br /> <h1>Gallery Number:</h1> <input type="text" name="gal" id="gal" /> <br /> <h1> </h1> <input type="submit" name="csv_btn" id="csv_btn" value="Submit" /> </form> </body> </html> when i run it on my local machine it works with no problem but when i upload it to my server and try to run it i get this error Code: [Select] Fatal error: Call to undefined function str_getcsv() in /html/admin/stats.php on line 14 |