PHP - Php 8's Attribute Feature Converted To Php 7 Compatible Attributes.
The following script came from using-custom-paths. It appears that these are PHP 8's new attributes, correct? <?php // api/src/Entity/Question.php #[ApiResource( subresourceOperations: [ 'api_questions_answer_get_subresource' => [ 'method' => 'GET', 'path' => '/questions/{id}/all-answers', ], ], )] class Question { }
I currently am using PHP7 and will need to convert them. Does the following look correct? Thanks /** * @ApiResource( * subresourceOperations = { * "api_questions_answer_get_subresource" = { * "method" = "GET", * "path" = "/questions/{id}/all-answers" * } * } * ) */
Similar TutorialsHi everybody
I am one stressed person right now.
I had been away for a while only to return recently and find out that none of my websites (with Hostpapa) had been working.
I sent the technical support team an email and they told me that my websites were not PHP 5.4 compatible.
They also said:
"As register_globals is deprecated in PHP 5.4 and because of this you are receiving errors on your website. You will have to update your website code and remove register global references. If this can not be done then in that case the last option would be to upgrade to VPS hosting."
Why have things just suddenly changed?
How can I fix this problem?
It's affected many of the sites on my host - and in some cases - the submission forms are not working in connection with my Aweber account.
Please help as this has shocked me quite badly - and needs resolving asap.
Thank you in advance
Hey all, I am not familiar with php coding at all and was wondering if anyone could help me re-code the below to being php 7 compatible. After using a php testor, it says mysql_connect is deprecated and needs to use the alternative mysqli_connect instead. How would I rewrite the below to be in the mysqli_connect format? Thank you in advance <?php $db = "MyDatabaseName"; //set this to the name of your database $host = "localhost"; //set this to the name of your host $user = "MyUserName"; //set this to your db user name $pass = "MyPassword"; //set this to your db password $con = mysql_connect("$host","$user","$pass"); $table = "MyDatabaseTableName"; //set this to the name of the table that holds the card info. $con= mysql_connect("$host","$user","$pass"); if(!$con) { $connect_error = "Failed at mysql_connect. "; echo"error at db connect"; exit(); } $tablewidth = "490";//set the main table width on the spread pages with this. $imagedirectory = "images/"; //main image directory $largeimagedirectory = "images/medium/"; srand((double)microtime()*1000000); ?>
PLEASEEE no matter what i do... datepicker always post the dates as string i do whatever ways know convert string to date but no way!! how convert string to date so i can sarch in a mysql table... tnx in advanced <!--HTML-->
<div class="control-group"> <!--PHP-->
$yfromx=$_POST['from'] ;
$t1=gettype ( $yfromx ) ;
I am preparing $begin and $end for DatePeriod() but I can't get passed this error "getting the error Recoverable fatal error: Object of class DateTime could not be converted to string". $today = date("Y-m-d"); $datestop=$_POST['datestop']; //echo "$today<br /><br />$datestop<br /><br />"; $begin = new DateTime("$today"); $end = new DateTime("$datestop");
Hi all
i am using the code below, but am getting the error
Object of class mysqli_result could not be converted to int
<?php $sql="SELECT lng,lng_prefix FROM tbl_languages where active = 1"; $result=mysqli_query($dbConn, $sql)or die(mysqli_error($dbConn)); //problem line if(mysqli_num_rows($result==1)){ ?>The code continues with what I want to happen based on the result. What does the error mean and how do I fix it? Hi guys, I have below values in array Code: [Select] stdClass Object ( [Category] => stdClass Object ( [ChildCategoryDescription] => 50s / 60s ERA [ChildCategoryID] => 87 [GrandchildCategoryDescription] => - [GrandchildCategoryID] => 25 [ParentCategoryDescription] => CONCERTS [ParentCategoryID] => 2 ) [Description] => Tony Bennett [ID] => 1073 [HomeVenueID] => 0 ) When am calling Desciption object by $resultsObj->Description then i got the result " Tony Bennett" but i do not know to get the value GrandchildCategoryID . Just i tried this Code: [Select] echo $resultsObj->$resultsObj->ParentCategoryID and i got below error. Catchable fatal error: Object of class stdClass could not be converted to string in D:\Program Files\xampp\htdocs\t1\genericLib.php on line 255. How i can get this value... Hi There, I'm feeling really dumb but i can't figure out how to get the data from an array that has been converted from xml so I can put it into a table. I've tried looping through based on simple array code but i just get array to string errors. my code looks like this $projects = array(); $xml=simplexml_load_string($response) or die("Error: Cannot create object"); foreach($xml->Jobs->Job as $item) { $projects[] = array( 'job_no' => (string)$item->ID, 'job_name' => (string)$item->Name, 'job_due' => (string)$item->DueDate, ); //array_sort_by_column($projects, 'job_due'); print_r($projects); print_r just dumps the whole lot on the page. Id like to grab each of those items and put them in a table cell then sort them by the due date etc. $job_no =""; $job_name =""; $job_due =""; //$item1 = $item->Client->Name; //$job_no = "$item->ID"; //$job_name = "$item->Name"; // $job_client = "$item1"; //$job_start = "$item->StartDate"; //$job_due = "$item->DueDate"; //$job_status = "$item->State"; $date = new DateTime($job_due); $due_date = $date->format('d-m-Y'); echo "<tr>"; echo "<td><a href='managejob.php?job_id=$job_no'><strong>$job_no</strong></td>"; echo "<td>$job_name</a></td>"; echo "<td>$job_priority</td>"; echo "<td>$job_status_1</td>"; echo "<td>$job_status_2</td>"; echo "<td>$job_status_3</td>"; echo "<td>$job_status_4</td>"; echo "<td>$job_status_5</td>"; echo "<td>$job_status_6</td>"; echo "<td>$job_status_7</td>"; echo "<td>$due_date</td>"; echo "</tr>"; } } Any help on this would be much appreciated. Thanks in advance. Everywhere I look for an answer to this there is a page and a half explanation about time zones and DST and different functions and unix epochs, gah. I made a login script that logs the gmmktime of when the user registered and there are now a bunch of members so I can't just go change the script, I definitely need a way to convert these timestamps to the date AND time that the timestamp was set, preferably in an easy to use way such as an array with "month" "day" "year" AND "time" in EST. Does anyone know of a way to do this? Every one I come across either converts it to just a date or to just grabs the time and makes it super confusing as to what it is converting to and questions what arguments were sent with gmmktime when it was set (hint: none were sent with it.) Thanks for any help. I notice plenty of CakePHP plugins don't have composer.json files in their github repositories (I'm not sure where composer downloads from if you don't specify a repository, is it github?) so I can't automatically download and update them. For composer to recognise and download the plugins, all thats needed is the composer.js file itself isn't it? Why wouldn't plugin authors just spend an extra 10 minutes and make a composer.js file? I'm guessing theres something I'm missing here, it must not be that simple. I only started using composer so I don't really know what its about yet.
The following is an extract of PHP code I have interacting with a MySQL database and I keep getting the "object of class mysqli_result could not be converted to string" error on the line of code inside my loop. This is my code.
#This is just storing a single integer, a moduleID
$sqlmodID = mysqli_query($con,"select moduleID from module_details WHERE moduleName = '$moduleName' AND lecturerID = '$lecturerID'"); #This is a query to get relevant idNumbers $sqlstudent = "select idNum from user_info WHERE courseCode = '$courseCode'";
#Running the previous statement $result = mysqli_query($con, $sqlstudent);
#Storing the statements results in an array $row = mysqli_fetch_array($result);
#I'm not sure if this line is necessary but it converts the array values into a string (I'm storing the ID's as strings as they contain numbers and letters) $studentArray = array_map('strval', $row);
#The error flashes on my condition of this loop. I'm trying to take each element of my array, and enter it to my table, assigning each variable the same ModuleID.
for($i=0; $i < count($studentArray); $i++){
Any help would be much appreciated. I hope I've explained my code sufficiently. why do i keep getting this error from line 7? Object of class stdClass could not be converted to string Code: [Select] <?php include_once"../includes/db_connect.php"; $item_number="2"; $custom="54298"; $query=mysql_query("SELECT `prodID`, `quanity` FROM `cart` WHERE `sessID`='$custom'") or mysql_error(); while($cart=mysql_fetch_object($query)){ mysql_query("INSERT INTO `orderItems` ( `id` , `orderInfoID` , `productID` , `quanity` ) VALUES ('', '$item_number', '$cart-> prodID', '$cart->quanity');"); } mysql_query("UPDATE `cart` SET `show`='1' WHERE `sessID`='$custom'"); ?> I'm receiving the error "Object of class player could not be converted to string" yet I cannot find why what I'm inputting is an object and not a string. As far as I can see it is a string and this error shouldn't be happening, yet it is... A form submits to a page which gets the data thus: Code: [Select] <?php case "updplayer": if(!isset($_GET['id']) || !isset($_POST['kit']) || !isset($_POST['level']) || !isset($_POST['group']) || !isset($_POST['state'])) { header("location:admin.php?mode=settings&error=info&sid=$user->sid"); exit; } $var = "player" . $_GET['id']; $$var->kit = mysql_real_escape_string($_POST['kit']); $$var->level = mysql_real_escape_string($_POST['level']); $$var->group = mysql_real_escape_string($_POST['group']); $$var->state = mysql_real_escape_string($_POST['state']); $$var->update(); header("location:admin.php?sid=$user->sid"); exit; break; The update function is: Code: [Select] <?php function update() { echo "Name: $this->name <br /> Kit: $this->kit <br /> Level: $this->level <br /> Group: $this->group <br /> State: $this->state <br />"; $sql = "UPDATE `players` SET `name` = '" . $this->name . "', `preferredKit` = '" . $this-kit . "', `gamingLevel` = '" . $this->level . "', `group` = '" . $this->group . "', `draftState` = " . $this->state; if(!mysql_query($sql)) { return mysql_error(); } return TRUE; } I added the echo's in for error checking. They output exactly what was expected. What is wrong with this? Error occurs on the "$sql = " line. 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? I'm using the wordpress themeplate, that has feature box in main page, which it use the feature images that has been listed on the pages, and it has this little icons that swtich them around every few second, now i need to have a small modification. i need the hover that is appearing on the top of the small boxes to show the tittle center, and also i need it to be linked (a href) to their pages... and the main background photo to be linked to that page as well. please help me url: http://www.makooliprekupec.com/en/ Hi All, I am a newbie and was designing a feature and needed some help. Wondering if i can get some help here. Here is the scenario. I have a website which has an Add Page. In the Add Page, customers can add address details and other information. Sometimes the customers might want to select an address from the existing address database. I have a button on the Add Page, which opens a new window which displays the addresses which can be used. When the customer selects an Address and clicks on the USE button, an POST is done to a new Add Page which displays the address. There is a slight glitch here. When the customers press on the USE button, a new Add Page is opened again in the same window. So how we have two instances of the Add Page. Now what I want to accomplish is that when the customer presses on the USE button, the new window should close and the already opened Add Page should display the selected Address. Is there a way to do this? I would greatly appreciate any input. Thank you, I have made a script to upload a few files from the pc to my server.. like i upload big files which are generally above 50mb of size.. but most of the times as there is some problem with the internet the hours of wait is just ruined.. is there a better way to upload files.. or anything that if the internet connection is interupted the downloading starts from wer it stopped cuz of the problem.. please help.. i use the normal function for uploading a file move_uploaded_file($_FILES['song1_upload']['tmp_name'] can anyone give a better idea than this? We want to add a chat feature in PHP for a social site can somebody suggest a good solution, a script maybe, where registered users when online can chat with other registered members in the friend list I have made a script to upload a few files from the pc to my server.. like i upload big files which are generally above 50mb of size.. but most of the times as there is some problem with the internet the hours of wait is just ruined.. is there a better way to upload files.. i use the normal function move_uploaded_file($_FILES['song1_upload']['tmp_name'] can anyone give a better idea than this? |