עבור לתוכן
View in the app

A better way to browse. Learn more.

HWzone

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

בעיה במערכים ב- PHP...

Featured Replies

פורסם
שלום רב,


אני זקוק לעזרה בנוגע לבעיה כללית שבה ניתקלתי עם המערך בקוד הבא:

<?php
error_reporting(E_ALL ^ E_NOTICE);
$filename="processes.txt"; //Read File
$handle=fopen($filename,'r');
$index = 0;
$LineArray = array(); //Create An Array That Holds All Of The Lines
if (is_readable($filename))
{//reads Lines To An Array:
while(!feof($handle)){
$CurrentLine = fgets($handle);
$LineArray[$index] = $CurrentLine;
$index = $index + 1;
}}
fclose($handle);
$index -= 3;
while($index>=0){ //Display The File Back To The HTML
$display .=
'<li class="menu">
<a href="" onclick="Msg('.$index.');">
<img alt="Description" src="thumbs/other.png" />
<span class="name">'.$LineArray[$index].'</span>
<span class="arrow"></span>
</a>
</li>';
$index = $index - 1;
}
if(isset($_GET['process']))
{
$value = ($_GET['process']);
//$str = $LineArray[$value]; //This Line Doesnt Work Thats Why It's Deactivated
$str = $value; // This Line Works But It's No Good To Me
$newline=$str;
$filename="close.txt";
$handle=fopen($filename,'w');
fwrite($handle,$newline);
fclose($handle);
}
?>

פורסם

זה כי מה שמגיע לך מה-GET הוא מחרוזת, לא מספר. אתה צריך להמיר אותו למספר.

פורסם

קודם כל אתה בודק אם הוא קריא לפני שאתה פותח את הקובץ, זה דבר ראשון. דבר שני המשתנה $_GET['process'] חייב להיות מספר תמיד אז תעשה עליו intval(). ולא ציינת מה לא עובד לך, או איך אתה רוצה שזה יעבוד.

פורסם
  • מחבר

אוקיי,

כפי שכבר הבנתם אני מנסה לכתוב אל הקובץ מחרוזת אשר נמצאת במערך בשם: LineArray.

לאחר הטיפ שניתן לי הבעיה עדיין לא נפתרה אפילו אחרי שהמרתי את המשתנה Value ל-int.

אני כבר אובד עצות אולי בגלל שהכל מתבצע אצלי ב- AJAX?

$.ajax({type: "GET",url: "php/Main.php",data: { process : value }});

ארכיון

דיון זה הועבר לארכיון ולא ניתן להוסיף בו תגובות חדשות.

דיונים חדשים

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.